Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am trying to set a Apache reverse proxy so that requests get proxyed to another application running on 8080. However, I want some directories to be directly served rather than forwarded to proxy. What I want is:

http://localhost/ -> http:// localhost:8080/myapp
http:// localhost/images -> /var/www/html/images
http:// localhost/anything-else -> http:// localhost:8080/myapp/anyhthing-else

My current httpd.conf is

ProxyRequests Off
ProxyTimeout 600
ProxyPreserveHost On
ProxyPass / http:// localhost:8080/
ProxyPassReverse / http:// localhost:8080/
RewriteEngine On
RewriteRule ^/(.*) http:// localhost:8080/VirtualHostBase/http/%{SERVER_NAME}:80/myapp/VirtualHostRoot/$1 [L,P]

What configuration should I do to make the local path exception to work?

Thank you, Tania

share|improve this question

marked as duplicate by Jenny D, mdpc, MichelZ, Scott Pack, Andrew Apr 3 at 6:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

I found the solution.

To make an exclusion for /myapp, I need to add

ProxyPass /myapp !

as the first ProxyPass directive as exclusions should come before the general rule.

I also need to add

RewriteCond !^/myapp/(.*)

before RewriteRule to exclude it from RewriteRule

share|improve this answer