0

I have this simple reverse proxy setup in my docker container(apache) each mapped to a different microservice with two different docker containers.

#serviceOne 
ProxyPass /abc/xyz/ http://serviceOne:8080/abc/xyz/ Keepalive=On
ProxyPassReverse /abc/xyz/ http://serviceOne:8080/abc/xyz/


#servicetwo 
ProxyPass /abc/xyz/pqr/ http://servicetwo:8080/abc/xyz/pqr/ Keepalive=On
ProxyPassReverse /abc/xyz/pqr/ http://servicetwo:8080/abc/xyz/pqr/

With this in place, I am not able to reach any relative route in the second service such as /abc/xyz/pqr/testprocess is not reachable, while it works properly when only single reverse proxy route is kept.

1 Answer 1

2

This was quite obvious and I actually could get it while framing this question :)

in such cases, what matters is the order in which these mappings are placed.

#servicetwo 
ProxyPass /abc/xyz/pqr/ http://servicetwo:8080/abc/xyz/pqr/ Keepalive=On
ProxyPassReverse /abc/xyz/pqr/ http://servicetwo:8080/abc/xyz/pqr/

#serviceOne 
ProxyPass /abc/xyz/ http://serviceOne:8080/abc/xyz/ Keepalive=On
ProxyPassReverse /abc/xyz/ http://serviceOne:8080/abc/xyz/

Just changing the order of these two mappings resolved the issue.

Although this was quite obvious, I could not find anything about reverse proxy URL order in apache documentation.

Even google could not return any solution or might be I could not frame the question properly.

If others could add more technical explanation to this answer, It will be great.

EDIT: There is a clear note about this in the documentation at https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#:~:text=ordering%20or%20override.-,Ordering%20ProxyPass%20Directives,URL.%20Note%20that%20there%20is%20some%20relation%20with%20worker%20sharing,-.

2
  • 1
    Quote from the ProxyPass documentation: The configured ProxyPass and ProxyPassMatch rules are checked in the order of configuration. The first rule that matches wins. So usually you should sort conflicting ProxyPass rules starting with the longest URLs first. Otherwise, later rules for longer URLS will be hidden by any earlier rule which uses a leading substring of the URL. Note that there is some relation with worker sharing.. They even put a red border around it. Commented Jan 19, 2022 at 7:12
  • I missed that. thanks @GeraldSchneider
    – Rajendra
    Commented Jan 21, 2022 at 3:03

You must log in to answer this question.

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