Replace string on proxy request

We are using nginx as a reverse proxy, and we want to modify some
strings on the body response.

The problem is this one:

http://www.doman.com → proxied to → http://192.168.0.0/

We get into the body response links like: http://192.168.0.0/0.gif.

How can we replace 192.168.0.0 by domain.com?

Thnx in advance for your help!

Posted at Nginx Forum:

On Mon, Apr 19, 2010 at 12:55:10PM -0400, Alberto wrote:

We are using nginx as a reverse proxy, and we want to modify some strings on the body response.

The problem is this one:

http://www.doman.com → proxied to → http://192.168.0.0/

We get into the body response links like: http://192.168.0.0/0.gif.

How can we replace 192.168.0.0 by domain.com?

You may replace single string using

    sub_filter  http://192.168.0.0  http://www.domain.com;

However, it’s better to configure backend to use “www.domain.com”.


Igor S.
http://sysoev.ru/en/

On Mon, Apr 19, 2010 at 09:19:45PM +0400, Igor S. wrote:

How can we replace 192.168.0.0 by domain.com?

You may replace single string using

    sub_filter  http://192.168.0.0  http://www.domain.com;
      sub_filter_once off;


Igor S.
http://sysoev.ru/en/

Thnx!!!

But from what I’m seeing we will have to compile nginx, as we are using
the version from jdub’s ppa and it has none of them.

Posted at Nginx Forum:

Igor S. at 2010-4-20 1:21 wrote:

http://www.doman.com → proxied to → http://192.168.0.0/
sub_filter_once off;

If you want regular expression substitution, you can try my module:

http://code.google.com/p/substitutions4nginx/


Weibin Y.