Apache Trailing Slash Problem

I was helping our IT guys out this past weekend configuring a reverse proxy load balancing environment for JBoss/Tomcat behind Apache. I kept running into problems where requests coming from Apache looked like:
GET /foo//bar instead of GET /foo/bar

Unfortunately this was causing NPEs and resource not found errors in a third party servlet filter we are using to combine some our static resources. This is the Apache configuration that seems to have resolved the problem, I just wanted to post it here in case I ran up against it again.

# Placed in Apache conf for the site
<Proxy balancer://app_cluster >
BalancerMember http://app1/foo
BalancerMember http://app2/foo
BalancerMember http://app3/foo
ProxyPass /foo/ balancer://app_cluster/ stickysession=JSESSIONID
ProxyPassReverse /foo/ http://app1/foo/
ProxyPassReverse /foo/ http://app2/foo/
ProxyPassReverse /foo/ http://app3/foo/

The lesson here is attention to detail, especially your final slashes.

5 thoughts on “Apache Trailing Slash Problem”

  1. I’m having a problem where requests with non-trailing slashes are rewritten by the balancer to include the missing slash and the back-end server IP. I.e.: “http://loadbalanc.er/solr” becomes “”

    Any idea if this is related to your problem?

  2. Hi Chris

    It has been a while since I had to fool around with this stuff, but I think your ProxyPass configuration could be a possible cause of appending trailing slashes to your request. Check your ProxyPass and and ProxyPassReverse configuration to see if it includes a trailing slash or not.

Leave a Reply