1 path nginx absolute proxypass
我有一个代理页面:http://destsrv:8089/index.html
它包含指向绝对路径的链接,例如:href="/static/bootstrap/css/bootstrap.min.css"
nginx 配置如下:
location /admin/ {
proxy_pass http://destsrv:8089/;
}
Run Code Online (Sandbox Code Playgroud)
尽管在访问时http://myproxy/admin/index.html
它试图从以下位置获取 .css:
http://myproxy/static/bootstrap/css/bootstrap.min.css
但预期的是:
http://myproxy/admin/static/bootstrap/css/bootstrap.min.css
怎么做?
尝试这个
location /admin/ {
proxy_pass http://destsrv:8089/;
sub_filter_once off;
sub_filter "http://destsrv:8089/" "$scheme://$host/admin";
sub_filter 'href="/' 'href="/admin/';
sub_filter "href='/" "href='/admin/";
}
Run Code Online (Sandbox Code Playgroud)
您基本上想使用过滤器修复网址
| 归档时间: |
|
| 查看次数: |
3315 次 |
| 最近记录: |