nginx反向代理显示了代理的端口号
upstream mall {
server 1.1.1.1:10261 weight=1;
}
server
{
listen 80;
server_name vinehootest.test.cn;
location / {
proxy_pass http://mall;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Via "nginx";
}
}
问题
- 输入网址vinehootest.test.cn可以正常访问
- 但是输入vinehootest.test.cn/dist 却跳转到vinehootest.test.cn:10261/dist/
- 一直没有想明白是什么原因, 最后发现是静态资源出现了问题
upstream mall {
server 1.1.1.1:10261 weight=1;
}
server
{
listen 80;
server_name vinehootest.test.cn;
location / {
proxy_pass http://mall;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Via "nginx";
}
}
#添加静态资源访问路径就正常访问了
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
proxy_pass http://mall;
}
location ~ .*\.(js|css)?$
{
proxy_pass http://mall;
}