Httpd – mod_proxy and trailing slashes

httpdmod-proxyreverse-proxy

We use httpd and mod_proxy as a reverse proxy in front of our different web servers.

We have our www subdomain pointed to the reverse proxy, and mod_proxy directs requests
from there.

I haven't been able to come up with a concise way of saying this, so I'll just show:

If we have a web site at http://blah.example.com/my-web-app, we'll usually add a
line like this to the reverse proxy:

ProxyPass   /my-web-app      http://blah.example.com/my-web-app

so that a user can go to http://www.example.com/my-web-app. When the path
component of the request (/my-web-app in this case) is the same on both the
reverse proxy, and the web server, the trailing slash will get added automatically,
just like if someone went straight to http://blah.example.com/my-web-app.

However, if the path components are different, e.g.:

ProxyPass   /my-web-app      http://blah.example.com/some-other-path

then the trailing slash does not get added.

Is this behavior normal? Is there some configuration that could take care of
this?

Best Answer

Read carefully the section on ProxyPass in Apache httpd documentation (http://httpd.apache.org/docs/current/mod/mod_proxy.html). You can likely get around this behavior by explicitly specifying the trailing / for both arguments of the ProxyPass directive

ProxyPass   /my-web-app/      http://blah.example.com/some-other-path/