Rewrite HTTP responses in "reverse proxy" mode

Maxim Dounin mdounin at mdounin.ru
Tue Jul 5 16:19:48 MSD 2011


Hello!

On Tue, Jul 05, 2011 at 01:01:31PM +0200, Antoine Nguyen wrote:

> Hi all,
> 
> I'm trying to create a reverse proxy to serve a moodle site hosted
> in the LAN of my company. The site is available from the Internet
> but all links to static content in the HTTP responses are using the
> internal address. This is an issue with moodle, not with nginx.
> 
> Because I don't want to loose too much time on this, I'm trying to
> play with both sub and subs modules to rewrite all occurences of
> "internal address" to "external address" but without success.
> 
> I'm wondering if HTTP substition is intented to work in a reverse
> proxy context.

Yes.

Please note though that response must not be compressed by 
backend, i.e. you may want to add something like

    proxy_set_header Accept-Encoding "";

to nginx config.

You may also need to set sub_filter_types[1] as appropriate in your 
setup, by default it will only work on text/html.

[1] http://sysoev.ru/nginx/docs/http/ngx_http_sub_module.html#sub_filter_types

Maxim Dounin



More information about the nginx mailing list