21

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

1
  • 2
    this is not a duplicate of the question on mod_rewrite. its about mod_proxy.. Mar 25, 2015 at 23:38

1 Answer 1

30

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

0