浏览 3.2k
我在服务器8800端口启动了一个程序,监听443端口,现在想通过配置/nexus匹配到这个8800这个端口的程序上,但是导致静态资源请求的地址全部都变成了代理后的地址,请问这个是我哪里配置的问题吗?
nginx我是这样配置的:
listen [::]:443 ssl http2 default_server;
location / {
}
#nexus 保留/nexus
location /nexus {
proxy_pass http://localhost:8800;
}
location ^~/nexus/static {
proxy_pass http://localhost:8800/nexus/static;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}静态资源的请求域名全部变成了这种的,请求的是配置的代理后的地址:
http://localhost:8800/nexus/static/rapture/resources/loading-prod.css?_v=3.33.0-01&_e=OSS

按点赞数排序
按时间排序
通过修改成如下配置之后可以正常访问了:
location ^~/nexus {
proxy_pass http://localhost:8800/nexus;
sendfile off;
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 https; # 转发时使用https协议
proxy_request_buffering off;
proxy_buffering off;
}
0
回答于2021-10-09 13:54
这是子请求设计引入的复杂度,slice模块、mirror模块、auth_request模块、缓存的异步更新都使用到了子请求机制。
当业务逻辑复杂时,子请求可以简化逻辑,此时,r->main指向主请求,即客户端请求。
当子请求并发执行时,由于网络不可控,有可能子请求的响应先到达了,不能简单返回给客户端,因此过滤模块中会判断r == r->main
不支持,nginx发送普通文件时可以使用此指令提高性能。proxy_pass指向的是upstream,如果压缩需要配置upstream。
https://trac.nginx.org/nginx/ticket/965#comment:6
微信公众号
加入微信群