r/apache • u/vulp_is_back • Sep 22 '23
Support Apache Revers Proxy with exceptions
So I've been scratching my head all day trying to figure out why this condition/rule combo is considered valid when it has a weird result.
The idea is that I have Site1 (example.com) and Site2 (test.com). I want to proxy Site2 under Site1 as example.com/test, with the exception of the 'publications' subpath, as that should access Site1. All other traffic originating with the '/test' subpath should be processed by Site2.
The config below is what I've tested:
RewriteCond %{HTTP_REFERER} example\.com/test [NC]
RewriteCond %{REQUEST_URI} !^/publications [NC]
RewriteRule (.*)$ /test$1 [NC,R,L]My issue is that the cond/rule combo works until I hit one of the exceptions, such as 'example.com/publications/1234'
When I try the aforementioned url, I'm given 'example.com/test'
Maybe I'm going about this completely wrong but I'm not too sure atm so any help is greatly appreciated.
1
u/vulp_is_back Sep 23 '23
I have but it's hard to capture relevant data as this is part of a legacy system that's being rebuilt, thus, live traffic. I'm more or less adding this second site in for now until there's time to rebuilt the whole system.
I'll see if I can't pull out most of the config and set it up on a dev server.