Nginx的proxy_pass无法加载资产
问题描述:
我nginx的配置用的conf:
Nginx的proxy_pass无法加载资产
location /test {
proxy_pass http://127.0.0.1:10000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
它的工作,但没有全部资产。我检查元素,资产重定向到http://127.0.0.1:10000(绝对404),它应该是http://127.0.0.1:10000/test/asset.css。
需要咨询:)
PS:我的服务器使用angular2(NPM开始)
答
愿力量与你:
location/{
proxy_pass http://127.0.0.1:10000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location ~ ^/(images/|img/|javascript/|js/|css/|stylesheets/|flash/|media/|static/|robots.txt|humans.txt|favicon.ico) {
root /root/of/your/public/assets;
access_log off;
expires max;
}
如果我还有一个网站,是不是冲突? –
只需创建服务器块,将其放入服务器块配置中即可。 – regex