I have an application whith the next structure:

/application (html files)
/application/css (css files)
/application/img (images)
/application/classes -> I want this to redirect to a application server (JBoss)

How do I configure apache for this?
Why doesn't work if I do:

ProxyPreserveHost On
ProxyPass /application !
ProxyPass /application/css !
ProxyPass /application/img !
ProxyPass /application/classes http://jboss_server:8080/
ProxyPassReverse /application/classes http://jboss_server:8080
  • 2
    What do you mean 'it doesn't work'? Do you get an error in the logs? Does the server return a 404? Does the JBoss server get the request? If it does, is it a request it knows what to do with?
    – CK.
    Aug 13, 2009 at 13:49

4 Answers 4


Ensure, that the Servers have the same structure!

ProxyPass /application/classes http://jboss_server:8080/application/classes
ProxyPassReverse /application/classes http://jboss_server:8080/application/classes

You haven't to use the other proxypass values, because "classes" is under "application"! So the proxy will only be invoked if you use /application/classes and not if you use /application/img.


I think you have the syntax a bit wrong. Its supposed to be:

  ProxyPass /mirror/foo/ http://foo.com/

Perhaps something like this:

ProxyPass                  /         http://sso.domain.com/
ProxyPassReverse         /           http://sso.domain.com/
  • I think the contextroot as itself is the problem!
    – Martin K.
    Aug 13, 2009 at 14:29

I use mod_rewrite for that - this give some more power.

RewriteCond %{REQUEST_URI}                       !^/server-info
RewriteCond %{REQUEST_URI}                       !^/server-status
RewriteRule ^/application/classes(.*)          http://jboss_server:8080/$1   [P,L,NS]

First line will make HTTPd to serve any requested file that can found in DOCUMENT_ROOT without proxing the request down to app server. I have a separate set of static files that I deploy on the web servers.

Another two lines will prevent HTTPd server-* pages to be proxied down and therefore they will be served by HTTPd. You can add more of this exceptions so that they can be handled by HTTPd.

Directives ProxyPreserveHost and ProxyPassReverse may be also useful in this context.

  • mod_rewrite can be total overkill here! mod_proxy is absolutly enought for this use-case! mod_rewrite uses regular expressions which will slow down every request!
    – Martin K.
    Aug 13, 2009 at 14:28
  • That JBoss in the backed will die fare before HTTPd will get busy doing this regex. I agree this may be an overkill in this case... just another way of doing it.
    – user16611
    Aug 13, 2009 at 17:10

Probably would have been better implemented using AJP protocol instead of TCP over port 8080, using mod_proxy_ajp and the following rule:

<Location />
    ProxyPass ajp://jboss_server:8009/
    ProxyPassReverse ajp://jboss_server:8009/

Of course, this requires that you enable the AJP protocol on the Tomcat server in JBoss , which I think is off, by default?

If the way you are doing it works though, no need to change it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy