mod_proxy incorrect redirect behaviour

Posted by Kevin Loney on Server Fault See other posts from Server Fault or by Kevin Loney
Published on 2010-03-25T18:50:21Z Indexed on 2010/03/25 18:53 UTC
Read the original article Hit count: 566

Filed under:
|
|

In chrome this configuration causes an infinite redirect loop and in every other browser I have tried a request for https://www.example.com/servlet/foo is resulting in a redirect to https://www.example.com/foo/ instead of https://www.example.com/servlet/foo/ however this only occurs when I do not include a trailing / at the end of the request url (i.e. http://www.flightboard.net/servlet/foo/ works just fine).

<VirtualHost *:80>
    # ...

    RewriteEngine On

    RewriteCond %{HTTPS} off
    RewriteCond %{REQUEST_URI} ^/servlet(/.*)?$
    RewriteRule ^(.*)$ http://%{HTTP_HOST}$1 [R=301,L]
</VirtualHost>

<VirtualHost *:443>
    # ...

    ProxyPass /servlet/ ajp://localhost:8009/
    ProxyPassReverse /servlet/ ajp://localhost:8009/
</VirtualHost>

The virtual host on port 443 has no rewrite rules that could possibly causing the problem, the tomcat contexts being referenced do not send any redirects, and if I change the ProxyPass and ProxyPassReverse directives to:

    ProxyPass / ajp://localhost:8009/
    ProxyPassReverse / ajp://localhost:8009/

everything works fine (except for the fact everything from www.example.com is being passed to the proxy which is not the behaviour I want). I'm fairly certain this is a problem with the way I have my proxy settings configured because I did log all the rewrite output coming from apache and it was all correct.

© Server Fault or respective owner

Related posts about apache

Related posts about mod-proxy