httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Venkat Rangan" <venkat.ran...@clearwellsystems.com>
Subject RE: [users@httpd] Apache reverse-proxy config.
Date Fri, 21 Mar 2008 00:31:57 GMT
Nils,

Thanks very much for your help.

I have made some progress - but still do not have a solution. My snippet
from httpd.conf on the Proxy Server (192.168.121.214) is:

NameVirtualHost 192.168.121.214:8080

<VirtualHost 192.168.121.214:8080>
ServerName test1
ProxyPreserveHost On

ProxyPass /testcase1/app http://192.168.122.184/app
ProxyPassReverse /testcase1/app http://192.168.122.184/app
ProxyHTMLURLMap http://192.168.122.184/app /testcase1/app

ProxyPass /testcase2/app http://192.168.122.247/app
ProxyPassReverse /testcase2/app http://192.168.122.247/app
ProxyHTMLURLMap http://192.168.122.247/app /testcase2/app

ErrorLog c:/temp/test-error.log

</VirtualHost>

My goal is the following:

Browser sends requests to the following to the proxy. (I have my DNS set
to resolve test1 to 192.168.121.214)

Request-1:
http://test1:8080/testcase1/app

Request-2:
http://test1:8080/testcase2/app

I want the Proxy Server (192.168.121.214:8080) to route:
Request-1 to: http://192.168.122.184/app
Request-2 to: http://192.168.122.247/app

It doesn't work - produces a 404 Not Found error and the Proxy Server
has the following in its access.log.

192.168.12.127 - - [20/Mar/2008:16:00:28 -0700] "GET /testcase1/app
HTTP/1.0" 302 -
192.168.12.127 - - [20/Mar/2008:16:00:28 -0700] "GET /app/ HTTP/1.0" 404
202
192.168.12.127 - - [20/Mar/2008:16:15:31 -0700] "GET /testcase2/app
HTTP/1.0" 302 -
192.168.12.127 - - [20/Mar/2008:16:15:31 -0700] "GET /app/ HTTP/1.0" 404
202


On the other hand, if I create two separate VirtualHosts such as the
following.

NameVirtualHost 192.168.121.214:8080

<VirtualHost 192.168.121.214:8080>
ServerName test1
ProxyPreserveHost On

ProxyPass /app http://192.168.122.184/app
ProxyPassReverse /app http://192.168.122.184/app
ProxyHTMLURLMap http://192.168.122.184/app /app

ErrorLog c:/temp/test1-error.log

</VirtualHost>

<VirtualHost 192.168.121.214:8080>
ServerName test2
ProxyPreserveHost On

ProxyPass /app http://192.168.122.247/app
ProxyPassReverse /app http://192.168.122.247/app
ProxyHTMLURLMap http://192.168.122.247/app /app

ErrorLog c:/temp/test2-error.log

</VirtualHost>

Now, if I have DNS resolve both test1 and test2 to the same Proxy IP
Address (192.168.121.214), and issue http://test1:8080/app, or
http://test2:8080/app, everything works fine and the requests go to the
right Origin Servers. For success case, the Access Log has:

192.168.12.127 - - [20/Mar/2008:12:58:15 -0700] "GET /app HTTP/1.1" 302
-
192.168.12.127 - - [20/Mar/2008:12:58:15 -0700] "GET
/app/goToUserHome.do HTTP/1.1" 200 36175

Note that there is an additional JavaScript, in the response from the
Origin Server in both cases - 'wget http://192.168.122.184/app' on the
proxy produces the following HTML.

<html>
    <head>
        <title>Go To Home Page</title>
        <script language="JavaScript1.2">
            function goToHomePage() {
            	location.replace("/app/goToUserHome.do");
            }
        </script>
    </head>
    <body onLoad="goToHomePage()">
        &nbsp;
    </body>
</html>

For some reason, when I have two VirtualHosts, the JavaScript is
properly recognized and re-issued by the Proxy. If I have one
VirtualHost with two separate path-based ProxyPass, the above GET
doesn't happen.

Is there something I am missing in the Proxy httpd.config? Do I need
some kind of a re-write rule?

Thanks.


-----Original Message-----
From: Nils Jeppe [mailto:nils@pandemonium.de] 
Sent: Thursday, March 20, 2008 12:46 AM
To: users@httpd.apache.org
Subject: Re: [users@httpd] Apache reverse-proxy config.



On Wed, 19 Mar 2008, Venkat Rangan wrote:

> Is there anything I am missing?

Yes. Apache is not able to distinguish between your two virtualhosts,
and 
thus using the first one. Use NameVirtualHost on the IP (or *) in the
main 
part of your config and assign ServerName 's to each of the
virtualhosts. 
I think this should solve your problem.


Best wishes,
Nils




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


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