我正试图修复我的反向代理背后的一个行为不端的应用程序--基本上,它会将绝对URL放到页面中。
我的公寓看起来就像
...
location /openproject/ {
proxy_set_header Host <internal host>;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://<internal host>/openproject/;
sub_filter 'http:<internal url>' 'https:<external url>';
sub_filter_once on;
sub_filter_last_modified on;
}
...
<>中的东西被替换以保护我的主机。没错,行为不端的应用程序是OpenProject。
它似乎不起作用,调试也没有提到任何关于替换发生的事情。
我做错什么了吗?
nginx -V
TLS nginx版本: nginx/1.18.0构建于2021年3月25日(运行于2022年5月3日的-ffile-prefix-map=/build/nginx-q9LD4J/nginx-1.18.0=. 1.1.1o ),它支持启用配置参数:- with =‘-g -O2 OpenSSL-fstack现在前缀=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf -http-log-path=/var/log/nginx/access.log.log-path=/var/log/nginx/error.log-path=/var/lock/nginx.lock-pid-path=/run/nginx.pid-模块-path=/usr/lib/nginx/ --http-client-body-temp-path=/var/lib/nginx/body -http-temp-path=/var/lib/nginx/快速scgi http-代理-temp-path=/var/lib/nginx/代理-http-scgi-temp-path=/var/lib/nginx/scgi-http-uwsgi-temp-path=/var/lib/nginx/uwsgi with-compat-with-pcre-jit-with-http_ssl_module with-http_stub_status_module with-http_realip_module with-_auth_request_module --具有-http_v2_模块-与-http_dav_模块-与-http_片_模块-带有-http_sub_模块-具有-http_gunzip_模块-with-http_gzip_static_-with_gzip_static_
发布于 2022-06-28 00:01:19
找到这个https://marsbard.github.io/2016-07-30-replace-urls-behind-nginx-reverse-proxy/
似乎我需要的配置是:
location /openproject/ {
proxy_set_header Accept-Encoding ""; # no compression allowed or next won't work
sub_filter "http://<internal host>/" "https://<external host>/";
sub_filter_once off;
proxy_set_header Host <internal 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-Host $host:$server_port;
proxy_pass http://<internal host>/openproject/;
}
https://stackoverflow.com/questions/72710633
复制相似问题