0

In Apache2 HTTP I'd like to redirect or proxypass conditionally. For instance, I'd like to proxypass to a specific backend if the client's IP addr. is private. Otherwise, I'd like to redirect to "/".

<Location /whatever>
   <If "-R '192.168.0.0/16' || -R '172.16.0.0/12' || -R '10.0.0.0/8'">
       ProxyPass https://backend/
       ProxyPassReverse https://backend/
   </If>
   <Else>
        Redirect /
   </Else>
</Location>

The above configuration leads to this error message:

ProxyPass cannot occur within <If> section

Why not? In any case, is there a workaround?

Thanks

0

1 Answer 1

0

It seems that a Redirect can be within an If section, so this seems to do the job:

<If "! ( -R '192.168.0.0/16' || -R '172.16.0.0/12' || -R '10.0.0.0/8' )">
   Redirect /
</If>
ProxyPass ...

You must log in to answer this question.

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