Basic common commands of nginx
./nginx -t
-> nginx refresh configuration restart
./nginx -s reload
(2) view mount information -->
df -h
mount directory view, /etc/
Configuration forwarding operation between nginx servers
The most important part (set the proxy_set_header Host of the outer nginx 'Here write the domain name and port listened by the inner nginx';)
In this example: proxy_set_header Host 'test.picclife.cn:8888';
###外网的nginx请求配置如下###
upstream yingxiaoht {
server market-h5.picclife.cn:8888;
}
server {
listen 8888;
server_name localhost *.picclife.cn;
location /clt/ {
proxy_pass http://yingxiaoht;
proxy_redirect off;
proxy_set_header Host 'test.picclife.cn:8888';
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_max_temp_file_size 0;
proxy_connect_timeout 90s;
proxy_send_timeout 90s;
proxy_read_timeout 90s;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
# 此处是海报地址的路由配置
location /clt/jdImg/ {
proxy_pass http://yingxiaoht/clt/jdImg/;
proxy_set_header Host 'test.picclife.cn:8888';
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_max_temp_file_size 0;
proxy_connect_timeout 90s;
proxy_send_timeout 90s;
proxy_read_timeout 90s;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
}
##Intranet nginx configuration is as follows:
server {
listen 8888;
server_name localhost *.picclife.cn; ###这里监听的是外网nginx配置的hosts
root /picc/nginx/html;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-NginX-Proxy true;
gzip on;
gzip_min_length 1k;
gzip_comp_level 9;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
#挂载海报转发
location /clt/jdImg {
alias /clt/test;
autoindex on;
autoindex_exact_size off;
}
# H5后端转发配置
location /clt/ {
proxy_pass http://10.56.48.100:8082;
proxy_set_header Host $host;
}
# 挂载图片转发
location /file/pd {
alias /market/pd/test;
autoindex on;
autoindex_exact_size off;
}
}
Conclusion: The configuration ends here. The key point is the hosts configuration of the request header of nginx on the external network. Intranet nginx monitor serve