1. Common commands

Start nginx stops the service: Nginx -s stop nginx -s quit Nginx stop command the difference between stop and quit is that stop stops nginx quickly and does not save related information. Quit stops nginx in an orderly manner and saves related information. The effects of both nginx start and stop commands can be viewed through the Processes TAB in Windows Task Manager. Restart the service: 1) Tasklist /fi "imagename eq $server_port :$proxy_port :$server_port :$server_port :$server_port :$server_port: Host proxy_set_header host $host; Proxy_set_header x-real-ip $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;Copy the code

2. Common HTTP request configuration

Server {LISTEN 8203; location / { root /usr/www/validation-demo/h5-1-advance; index index.html; try_files $uri $uri/ /index.html; if ($request_filename ~* .*\.(? :htm|html)$){ add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate"; }} the location/API / {proxy_pass http://192.168.8.10:5001/; }} added the HTTPS front end separation configuration server {listen 443; server_name www.huzhihui.com; ssl on; ssl_certificate /etc/nginx/cert/5673168_www.huzhihui.com.pem; ssl_certificate_key /etc/nginx/cert/5673168_www.huzhihui.com.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:! NULL:! aNULL:! MD5:! ADH:! RC4; Ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; location / { root /alidata/view/eip-home; index index.html; try_files $uri $uri/ /index.html; if ($request_filename ~* .*\.(? :htm|html)$){ add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate"; } expires 7d; } location/API / {proxy_pass http://127.0.0.1:56000/; } } server{ listen 80; server_name www.huzhihui.com; rewrite ^/(.*)$ https://www.huzhihui.com/$1 permanent; } server{listen 80; server_name wx.huzhihui.cn; add_header Strict-Transport-Security max-age=15768000; location / { if ($request_method ~ ^(POST|DELETE|OPTIONS)$) { proxy_pass https://wx.huzhihui.cn; break ; } rewrite ^/(.*)$ https://wx.huzhihui.cn/$1 permanent; }} server{listen 80; server_name www.huzhihui.com; location /{ proxy_redirect default; Proxy_pass http://127.0.0.1:8093; proxy_set_header Host $host; Proxy_set_header Referer $http_referer; proxy_set_header X-Real-Ip $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; Upstream web_Servers {server localhost:8080; server localhost:8081; } server { listen 80; server_name www.huzhihui.com; location / { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://web_servers; } location ~.*\.(js|css)$ { root /opt/static-resources; expires 12h; } location ~.*\.(html|jpg|jpeg|png|bmp|gif|ico|mp3|mid|wma|mp4|swf|flv|rar|zip|txt|doc|ppt|xls|pdf)$ { root /opt/static-resources; expires 7d; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; }} server {listen 443; server_name www.huzhihui.com; ssl on; ssl_certificate cert-tues/214069203020278.pem; ssl_certificate_key cert-tues/214069203020278.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:! NULL:! aNULL:! MD5:! ADH:! RC4; Ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; Location / {proxy_pass http://127.0.0.1:9002/; proxy_redirect default; Proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } server{ listen 80; server_name www.huzhihui.com; rewrite ^/(.*)$ https://server.ourtues.com/$1 permanent; }Copy the code

3. Common TCP request configuration

stream { upstream backend { hash $remote_addr consistent; Server 127.0.0.1:7100 max_fails = 3 fail_timeout = 10 s. Server 127.0.0.1:7102 max_fails = 3 fail_timeout = 10 s. } server { listen 8000; proxy_connect_timeout 2s; proxy_timeout 5m; proxy_pass backend; }} Nginx based on connection detection, if the backend fails, max_fails reaches the number of times set in fail_TIMEOUT. Within this number of times, if the same backend node is unavailable, then the node will be marked as unavailable. And wait for the next cycle (also often fail_timeout) to request again to determine whether the connection was successful. If successful, the previous polling mode will be restored. If not, the next cycle (fail_timeout) will be tried again. Default: fail_timeout is 10s and max_fails is 1. Pay special attention to the TCP module's reverse proxy configuration in the STREAM moduleCopy the code