Article directory
1. Introduction to nginx
2. nginx common commands
Verify the configuration is correct: nginx - t View the detailed version number of Nginx: Nginx - V Check the concise version number of Nginx: Nginx - V Start Nginx: start Nginx Fast stop or close Nginx: Nginx - s stop Normal stop or close Nginx: Nginx - s quit Configuration file modify reload command: nginx - s reload
3. nginx configuration
3.1 configuration code
#user nobody; worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; #1 start upstream linuxidc { server localhost:7071; server localhost:7072; server localhost:7073; } server { listen 7070; server_name localhost; location / { # root C:/ngtest2; # index index.html index.htm; proxy_pass http://linuxidc; } } # 1 end #2 start server { listen 7071; server_name localhost; location / { root C:/ngtest1; # index index.html index.htm; #proxy_pass https://tms; #proxy_pass https://www.baidu.com/; } } server { listen 7072; server_name localhost; location / { root C:/ngtest2; # index index.html index.htm; #proxy_pass https://tms; } } server { listen 7073; server_name localhost; location / { root C:/ngtest3; # index index.html index.htm; #proxy_pass https://tms; } } # 2 end #3 start server { listen 8080; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; #location / { # root C:\ngtest; #index index.html index.htm; #proxy_pass https://www.baidu.com/; # } location /baidu { #root html; #index index.html index.htm; proxy_pass https://www.baidu.com/; } location /csdn { #root html; #index index.html index.htm; proxy_pass https://www.csdn.net/; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # 3 end } }
3.2 code description and renderings
3.2.1 different port agents and different applications
#2 start server { listen 7071; server_name localhost; location / { root C:/ngtest1; # index index.html index.htm; #proxy_pass https://tms; #proxy_pass https://www.baidu.com/; } } server { listen 7072; server_name localhost; location / { root C:/ngtest2; # index index.html index.htm; #proxy_pass https://tms; } } server { listen 7073; server_name localhost; location / { root C:/ngtest3; # index index.html index.htm; #proxy_pass https://tms; } } # 2 end
3.2.2 renderings
3.2.3 different applications of the same port number agent
#3 start server { listen 8080; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; #location / { # root C:\ngtest; #index index.html index.htm; #proxy_pass https://www.baidu.com/; # } location /baidu { #root html; #index index.html index.htm; proxy_pass https://www.baidu.com/; } location /csdn { #root html; #index index.html index.htm; proxy_pass https://www.csdn.net/; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # 3 end
3.2.4 renderings
3.2.5 load balancing
Default polling method
#1 start upstream linuxidc { server localhost:7071; server localhost:7072; server localhost:7073; } server { listen 7070; server_name localhost; location / { # root C:/ngtest2; # index index.html index.htm; proxy_pass http://linuxidc; } } # 1 end
3.2.6 renderings
If I think it's OK, I'll like it in the upper right corner.
If you have any inaccuracies or questions, you can communicate in the discussion area / QQ / wechat public account, thank you!