Forum Moderators: phranque
ProxyPass / [<TomcatWorkerIP>:<PORT>...]
ProxyPassReverse / [<TomcatWorkerIP>:<PORT>...]
Now I'd like to simplify the user login URL from
[dnsname...]
to
[dnsname...]
I've attempted to do this via mod_rewrite but am having problems. What I'd like to do is have the Apache rewrite occur first (BoxA), then have the results sent to the remote Tomcat worker (BoxB), all the while maintaining the requesting URL (http://dnsname/login).
I tried the following (httpd.conf):
RewriteEngine On
RewriteLog logs/rewrite.log
RewriteLogLevel 9
RewriteRule ^/login /appname/servlet/login [P]
<VirtualHost *:<PORT>
ServerName dnsname
ProxyRequests Off
ProxyPass / [<TomcatWorkerIP>:<PORT>...]
ProxyPassReverse / [<TomcatWorkerIP>:<PORT>...]
Errorlog logs/appname_access.log
</VirtualHost>
The above configuration works initially, but then fails on subsequent attempts.
Any ideas or thoughts? Thanks in advance.
First, be aware that you can't easily control module execution order on Apache 2.x, and even though you can control it on Apache 1.x, modifying the LoadModule list can often create unwanted side-effects. And even if it doesn't, you're still left with a solution that won't migrate to Apache 2.x.
The simplest solution is to use an intermediate URL-path, so that the ProxyPass directive is not invoked until after the rewrite. This can be done in many ways, but a simple example would be:
ProxyPass /proxy/
...
RewriteRule ^/login /proxy/appname/servlet/login [PT,L]
With the above in mind, review the mod_proxy and mod_rewrite documentation; I can't be sure I got this right, and there are of course many possible subtleties and interactions that you need to watch out for. The mod_proxy examples for reverse-proxy setup and the descriptions of the [P] and [PT] RewriteRule flags should be checked at a minimum.
Jim