Modify HTML pages returned by nginx reverse proxy

Solution 1:

Here is an official Nginx Video on YouTube which demonstrates Inline Content Rewriting.

https://youtu.be/7Y7ORypoHhE?t=20m22s

Indeed with sub_filter

http://nginx.org/en/docs/http/ngx_http_sub_module.html

In your case, you're looking at something like:

location / {
sub_filter_once off;
sub_filter_types text/html;
sub_filter "https://internalserver:8080" "https://proxyserver";
}

Solution 2:

http://nginx.org/en/docs/http/ngx_http_sub_module.html

The ngx_http_sub_module module is a filter that modifies a response by replacing one specified string by another.

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

Example Configuration

sub_filter      </head>
    '</head><script language="javascript" src="$script"></script>';