nginx的基本常用命令
./nginx -t
-> nginx刷新配置重啟
./nginx -s reload
(2)掛載信息查看 -->
df -h
掛載目錄查看,/etc/
nginx服務(wù)器之間的配置轉(zhuǎn)發(fā)操作
最重要的部分 (設(shè)置外層的nginx的 proxy_set_header Host ‘此處寫入內(nèi)層nginx監(jiān)聽的域名加端口’;)
本例子中是: proxy_set_header Host ‘test.picclife.cn:8888’;
###外網(wǎng)的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 'market-h5.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 'market-h5.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 "";
}
}
##內(nèi)網(wǎng)nginx配置如下:文章來源:http://www.zghlxwxcb.cn/news/detail-421264.html
server {
listen 8888;
server_name localhost *.picclife.cn; ###這里監(jiān)聽的是外網(wǎng)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]\.";
#掛載海報轉(zhuǎn)發(fā)
location /clt/jdImg {
alias /clt/test;
autoindex on;
autoindex_exact_size off;
}
# H5后端轉(zhuǎn)發(fā)配置
location /clt/ {
proxy_pass http://10.56.48.100:8082;
proxy_set_header Host $host;
}
# 掛載圖片轉(zhuǎn)發(fā)
location /file/pd {
alias /market/pd/test;
autoindex on;
autoindex_exact_size off;
}
}
結(jié)語:配置到此處就結(jié)束了,關(guān)鍵點在于外網(wǎng)的nginx的請求頭的hosts配置。內(nèi)網(wǎng)的nginx的監(jiān)聽serve文章來源地址http://www.zghlxwxcb.cn/news/detail-421264.html
到了這里,關(guān)于內(nèi)網(wǎng)nginx代理到外網(wǎng)nginx(nginx之間的轉(zhuǎn)發(fā)操作)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!