Replace image and javascript absolute paths through proxy_redirect in nginx

半城伤御伤魂 提交于 2019-12-04 19:24:18

In case where the proxied application (the Graphite app in this case) isn't able to be configured as a "slave" app, it is better to spare a whole subdomain to the application.

Or you may try the ngx_http_sub_module which:

…modifies a response by replacing one specified string by another.

as an example this code will change all the ':/localhost:8080/' to ':/localhost/app_name/':

location <app_name> {
    # ...
    sub_filter ':/localhost:8080/' ':/localhost/app_name/';
}

Note that:

This module is not built by default, it should be enabled with the --with-http_sub_module configuration parameter.

But in most package systems nginx is built with all it's optional modules already. Just check if you version has the sub_module built in:

nginx -V | grep sub_module

In my case for homebrew it gives output like this.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!