nginx的基本常用命令
./nginx -t
-> nginx刷新配置重启
./nginx -s reload
(2)挂载信息查看 –>
df -h
挂载目录查看,/etc/
nginx服务器之间的配置转发操作
最重要的部分 (设置外层的nginx的 proxy_set_header Host ‘此处写入内层nginx监听的域名加端口’;)
本例子中是: 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 "";
}
}
##内网nginx配置如下:
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;
}
}
结语:配置到此处就结束了,关键点在于外网的nginx的请求头的hosts配置。内网的nginx的监听serve