How do I rewrite URLs in a proxy response in NGINX

前端 未结 3 1282
庸人自扰
庸人自扰 2020-11-28 19:42

I\'m used to using Apache with mod_proxy_html, and am trying to achieve something similar with NGINX. The specific use case is that I have an admin UI running in Tomcat on

3条回答
  •  广开言路
    2020-11-28 20:29

    You may also need the following directive to be set before the first "sub_filter" for backend-servers with data compression:

    proxy_set_header Accept-Encoding "";
    

    Otherwise it may not work. For your example it will look like:

    location /admin/ {
        proxy_pass http://localhost:8080/;
        proxy_set_header Accept-Encoding "";
        sub_filter "http://your_server/" "http://your_server/admin/";
        sub_filter_once off;
    }
    

提交回复
热议问题