httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Folini <christian.fol...@post.ch>
Subject Re: [users@httpd] Need help to deal with poorly written PHP apps behind Apache used as Reverse Proxy
Date Mon, 22 Oct 2007 06:30:41 GMT
On Fri, Oct 19, 2007 at 09:09:54PM +0200, Alan AZZERA wrote:
> > RewriteRule /(.*)  http://backend/$1 [proxy,last]
> 
> But AFAIK, mod_rewrite cannot alter anything *inside* the HTML code
> going out the server. mod_proxy_html can...

yep.

> I'm currently trying to deal with PMWiki. It uses only HTTP_HOST. The
> problem with this application is that developpers use HTTP_HOST to
> construct absolute URL everywhere in the HTML code their PHP generate,
> even in CSS and Scripts. Pfouark !

Typical behaviour. 

Try to do it the following way with mod_proxy, mod_rewrite and
mod_headers.

RewriteRule /(.*)  http://backend/$1 [proxy,last]

<Proxy ...>
   RequestHeader  set    Host    "www.example.com"
   ...


This should trick your wiki to use www.example.com to generate
the correct HTML code without the need to rewrite the response.

If you want to get your hands really dirty, you can also
leave mod_headers aside and set www.example.com statically
in /etc/hosts to point to the backend. That way the proxy
server will still believe that he is www.example.com via
servername, but when you proxy to www.example.com it will
go to the backend via /etc/hosts with the right host-header
to let the backend generate the correct URLs. Not that I 
would recommend it, but I have seen this in practice...

regs,

Christian

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message