Implementation function: port forwarding
For example what I actually run is ·
http:localhost:5000
but I want to access via localhost:80.
Process
2 Unzip to a directory (for example, I put it in the root directory of the C drive)
3 Enter the directory (C:\nginx-1.14.0) mine is C drive, different directories are different.
4 Open a command line window in this directory, execute start nginx
or start nginx.exe
, and the window will flash by.
5 Check whether nginx is running normally: the command line window tasklist /fi "imagename eq nginx.exe"
can be seen if it is running normally
If you don't see the running process going into the directory logs
, look at the file error.log
to see the specific error.
I also got an inability to run error at first, with the following error message:
2018/04/22 20:36:14 [emerg] 10404#316: bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)
Later, delete the IIS default binding default
site to solve the problem.
6. Edit the fileC:\nginx-1.14.0\conf\nginx.conf
Modify the content under its server node:
Original content:
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
After modification:
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass https://localhost:5001;
# root html;
# index index.html index.htm;
}
Only one line was added proxy_pass https://localhost:5001
, the next two lines were commented out.
7 Reload nginx,nginx -s reload
8 visitshttp://localhost
Run successfully.
notes
Order | explain |
---|---|
nginx -s stop | forced stop |
nginx -s quit | Exit normally |
nginx -s reload | Change the commands used in the configuration file, start a new process with the new configuration file, and then launch the old process normally. |
nginx -s reopen | Reopen the log file. |
Ubuntu's nginx default configuration file is /etc/nginx/conf.d/default.conf
below .