nginx反向代理web網(wǎng)站時(shí),容易出現(xiàn)css和圖片丟失的情況,要解決這個(gè)問題
需要添加location ~ .*
如:
server {
listen 80;
server_name abc.ccc.com;
location / {
proxy_pass http://172.16.11.11:8088/samc/;
#添加代理header
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;
#set_real_ip_from 0.0.0.0/0;
#real_ip_header X-Forwarded-For;
}
location /myweb/ {
proxy_pass http://172.16.11.11:8088/samc/;
#添加代理header
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;
#set_real_ip_from 0.0.0.0/0;
#real_ip_header X-Forwarded-For;
}
location ~ .*(/myweb).*\.(js|css|jpg|jpeg|gif|png|ico|pdf|txt)$ {
proxy_pass http://172.16.11.11:8088; #匹配實(shí)際端的口地址(這里不能加入項(xiàng)目名)
}
location ~ .*\.(js|css|jpg|jpeg|gif|png|ico|pdf|txt)$ {
proxy_pass http://172.16.11.11:8088;
}
}
好了,這篇文章的內(nèi)容發(fā)貨聯(lián)盟就和大家分享到這里,如果大家網(wǎng)絡(luò)推廣引流創(chuàng)業(yè)感興趣,可以添加微信:80709525 備注:發(fā)貨聯(lián)盟引流學(xué)習(xí); 我拉你進(jìn)直播課程學(xué)習(xí)群,每周135晚上都是有實(shí)戰(zhàn)干貨的推廣引流技術(shù)課程免費(fèi)分享!