View Full Version : [all variants] Apache2 mod_proxy mod_rewrite

December 17th, 2008, 11:59 AM
Hi everybody,

I've been 4 days trying to do something I thought would be easy, but I'm having a lot of problems.

So, what I want to do is FORWARDING web petitions from 1 webserver to another.

Well, this is the scenary:

1 router, and 3 Servers (S1, S2, and S3), and a domain http://www.example.com
S1 -, S2 -, S3 -
S1 is the Server where Router sends all peticions throught the port 8080
S3 is the Server where Router sends all peticions throught the port 80

The objective is that when I write http://www.example.com:8080, S1 sends me to S2.

So, I followed these steps:

Enable needed modules:

a2enmod rewrite
a2enmod proxy
a2enmod proxy_http

apache restart

Edit /etc/apache2/mods-enabled/proxy.conf

<IfModule mod_proxy.c>
ProxyRequests Off
<Proxy *>
AddDefaultCharset off
Order deny,allow
Allow from all
ProxyVia On

Create /etc/apache2/sites-available/example

NameVirtualHost *:8080
<VirtualHost *:8080>
<Proxy *>
Order deny,allow
Allow from all
ServerName www.example.com
RewriteEngine on
ProxyPass /
ProxyPassReverse /

Enable the new site

a2ensite example

Finally I restarted apache and added www.example.com to my /etc/hosts file.

Well, when I tried it, I see the login page of my web application in, but when I login, I get this error:

Proxy Error

The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request POST /login.

Reason: DNS lookup failure for:

Apache/2.2.3 (Debian) Server at egestio.ditecsa.com Port 8080

Anybody knows whats the problem?

Thanks a lot friends.

December 25th, 2008, 04:50 AM
Try adding a trailing "/" to So it would be

ProxyPass /
ProxyPassReverse /