8

I have configured my VirtualHost example.com to proxy all requests to a Tomcat server

ProxyPass / http://localhost:8088/app
ProxyPassReverse / http://localhost:8088/app

This works fine for URLs like example.com/page, but for example.com and example.com/ I get this redirection response, which obviously leads to nothing.

HTTP/1.1 302 Moved Temporarily
Date: Wed, 06 Jul 2011 21:13:37 GMT
Server: Apache-Coyote/1.1             <-- the redirect comes from tomcat
Location: http://example.com/app/     <-- nonsense
...

What can I do to fix it? Preferably in the Apache config.

I'm using Apache 2 and Tomcat 7

Bart van Heukelom
  • 1,199
  • 6
  • 21
  • 41

1 Answers1

12

I'm not exactly sure why, but this is the fix

ProxyPass / http://localhost:8088/app/
ProxyPassReverse / http://localhost:8088/app/

(Added slashes to the end)

Bart van Heukelom
  • 1,199
  • 6
  • 21
  • 41
  • 9
    Slashes should always match. From the [mod_proxy documentation](http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypass): `If the first argument ends with a trailing /, the second argument should also end with a trailing / and vice versa. Otherwise the resulting requests to the backend may miss some needed slashes and do not deliver the expected results.` – Shane Madden Jul 06 '11 at 21:43