Score:0

Apache reverse proxy routes with similar partial url

br flag

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.

Score:1
br flag

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,-.

in flag
Quote from the [ProxyPass documentation](https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypass): `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.
br flag
I missed that. thanks @GeraldSchneider
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.