Reverse proxy and html rewrite

Hi there,

I’d like to know if nginx supports html rewrite when configured as a
reverse proxy.

My problem is that the site I’d like to RP set the full server URL in
the login form to force the login in HTTPS, ie sth like:

....

While, for the browser, it accesses the site with
http://localhost:2080 or https://localhost:2443

Is there a way to configure nginx to take this into account ?

Thanks & regards,
Manuel

Hi

As far as I know body content rewriting it’s not possible with nginx, I
may be wrong, i’m a newbie with nginx.
What nginx supports is URL rewriting through HttpRewrite module and this
has nothing to do with returned body content rewriting.

URL Rewriting works when nginx receives a requests, it parses the URL
requested and rewrite as appropiate according to your rules. At this
point the call have not been made to the real request. It doesn’t matter
where the real call (after rewriting is done) is then sent, be it
reverse proxy, static, fcgi daemon, whatever you want.

What do you want is to rewrite the content that the backends returns,
that’s not something you can do with the HttpRewrite module.

What indeed you can do to solve your problem is to setup nginx to accept
ssl connections for that site, let the login form send users to ssl and
inside ssl server config in nginx place a 301 redirect to your http
server.

Cheers

Guzman

Posted at Nginx Forum:

On 8 Out 2010 12h56 WEST, [email protected] wrote:

Hi

As far as I know body content rewriting it’s not possible with
nginx, I may be wrong, i’m a newbie with nginx. What nginx supports
is URL rewriting through HttpRewrite module and this has nothing to
do with returned body content rewriting.

It can: Module ngx_http_sub_module

And there’s a third party module that does more elaborate replacements:

http://wiki.nginx.org/HttpSubModule

Of course nginx must “own” those locations where content rewriting is
to be done.

— appa

On 8 Out 2010 14h58 WEST, [email protected] wrote:

And there’s a third party module that does more elaborate
replacements:

Module ngx_http_sub_module
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
http://wiki.nginx.org/NginxHttpSubsModule

— appa

Sweet! Every day I love nginx more!

Do you know if it add too much load on it to check every returned html
content?

Whenever this module allow regular expressions (right now says there it
accepts only variables) and allow to redirect user on match to another
page,
this would be a nice replacement for apache2 mod_security body parse
feature.

Thanks for the info, as I said I’m still a newbie with nginx :slight_smile:

Ok thanks all for the links & proposal.

Cheers,
Manuel

I actually have this working with httpsubmodule, but it doesn’t seem to
rewrite any files that are .php, .aspx. Only .html files, is this an
Nginx issue?

Posted at Nginx Forum:

its to do with gzip, ive seen the same thing when the backend gzip
encodes.

Hello,

You have to disable GZip on the backend web servers: Apache and IIS.

Olivier

Posted at Nginx Forum:

How can you disable the Gzip? Would it be on NGINX or the web servers?
The web server serving up PHP is apache 2 and ASPX is IIS 7

Posted at Nginx Forum: