# Rewrite HTTP responses in "reverse proxy" mode

**URL:** <https://www.ruby-forum.com/t/rewrite-http-responses-in-reverse-proxy-mode/209085>\
**Category:** NGINX\
**Created:** [July 5, 2011, 1:01pm UTC](https://www.ruby-forum.com/t/rewrite-http-responses-in-reverse-proxy-mode/209085 "2011-07-05T13:01:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [July 5, 2011, 1:01pm UTC](https://www.ruby-forum.com/t/rewrite-http-responses-in-reverse-proxy-mode/209085/1 "2011-07-05T13:01:51Z")

</div>

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.

Thanks for your help,

Antoine Nguyen.

---

<div class="post-metadata">

**Author:** ![Antoine\_Nguyen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eb9ed0/32.png) [@Antoine\_Nguyen](https://www.ruby-forum.com/u/Antoine_Nguyen)\
**Post date:** [July 5, 2011, 2:52pm UTC](https://www.ruby-forum.com/t/rewrite-http-responses-in-reverse-proxy-mode/209085/2 "2011-07-05T14:52:41Z")

</div>

On 05/07/2011 14:19, Maxim D. wrote:

> > 
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)  
> I’ve just found what was the problem before reading your answer : the  
> backend had “mod\_deflate” enabled by default. It works well now.

By the way, many thanks for your answer Maxim, it was exactly what I  
needed 🙂

–  
Antoine Nguyen  
Modoboa developer

> **[Open Source Email Server](https://modoboa.org/en/)**
>
> Modoboa is an open source email server including a modern and simplified Web User Interface.

---

<div class="post-metadata">

**Author:** ![Antoine\_Nguyen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eb9ed0/32.png) [@Antoine\_Nguyen](https://www.ruby-forum.com/u/Antoine_Nguyen)\
**Post date:** [July 5, 2011, 2:20pm UTC](https://www.ruby-forum.com/t/rewrite-http-responses-in-reverse-proxy-mode/209085/3 "2011-07-05T14:20:33Z")

</div>

Hello!

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

> 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]

> **[Модуль ngx\_http\_sub\_module](http://nginx.org/ru/docs/http/ngx_http_sub_module.html)**

Maxim D.
