Nginx proxy_pass位置绝对路径

时间:2017-09-13 08:41:35

标签: nginx path absolute proxypass

我有一个代理页面:http://destsrv:8089/index.html 它包含绝对路径的链接,如:href="/static/bootstrap/css/bootstrap.min.css"

nginx的配置如下:

 location /admin/ {
              proxy_pass http://destsrv:8089/;
        }

虽然访问http://myproxy/admin/index.html时 它试图从.css: http://myproxy/static/bootstrap/css/bootstrap.min.css

但预计是: http://myproxy/admin/static/bootstrap/css/bootstrap.min.css

怎么做?

1 个答案:

答案 0 :(得分:2)

试试这个

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/";
}

您基本上想要使用过滤器修复网址