0

I have apache running on a natting fw, that authenticates, reverse proxies, and provides an ssl wrapper for 2 webapps on the back end. This works with virtual hosting and proxies back based on the top level directory of the request, e.g. https://example.com/app1/ <-> http://app1/app1/. (see fig1)

I would like to find a way to proxy back a request to a webservice based on an arbitrary header set in the request, e.g. if header web_service:coolwebservice is set, it proxies back to webservice:8000. Is this even possible?

fig1      [Apache:example.com:443 / FW / NAT]
                          |
       ┌------------------┬------------------┐
       |                  |                  |
       V                  V                  V
[app1:80 /app1/]  [app2:8080 /app2/] [web_service:8000]     

1 Answer 1

2

Yes, this is absolutely possible with mod_rewrite, something like this should do the trick:

RewriteCond %{HTTP:web-service} coolwebservice
RewriteRule ^/(.*) http://web_service:8000/$1 [P,L]

With %{HTTP:...} you can inspect aritrary headers and make your decisions based on that.

1
  • Thanks! I think I ended up working around this because I couldn't figure it out, but I'll revisit it.
    – MattPark
    Mar 2, 2014 at 17:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .