How to perform proxypassreverse with regex
In order to use a regex you must use ProxyPassMatch:
ProxyPassMatch ^/server-(\d+)/$ server-$1.{My server}
The purpose of ProxyPassReverse
is to fix any Location headers that the proxy server issues for itself. For example if I proxy mywebsite.com to bluewebsite.com and bluewebsite.com issues a redirect to bluewebsite.com/1, ProxyPassReverse will intercept it and redirect me to mywebsite.com/1 instead.
If your proxy server issues redirects to the proper front-end URLs (or does not use redirects) then ProxyPassReverse is not needed. If you do need it, you are out of luck in this example because it does not accept regexes.
Here is another question that might help you: ProxyPassMatch with ProxyPassReverse
MKAfridi
Updated on June 09, 2022Comments
-
MKAfridi almost 2 years
I am stuck in this problem for past few days, I am using reverse proxy of Apache server and I managed to run the reverse proxy by making the following changes in config file:
ProxyPass: /server-01/ server-01.{My server} ProxyPassReverse: /server-01/ server-01.{My server} ProxyPass: /server-02/ server-02.{My server} ProxyPassReverse: /server-02/ server-02.{My server} ProxyPass: /server-03/ server-03.{My server} ProxyPassReverse: /server-03/ server-03.{My server} ProxyPass: /server-04/ server-04.{My server} ProxyPassReverse: /server-04/ server-04.{My server}
All this is working but I want to make this dynamic so that I dont have to add new code and restart Apache when a new proxy server is added!
-
Edik Mkoyan about 6 yearsHow to deal with location headers with no hostnames, like this one Location: /en/product? My problem is even worse. I want to prepend different strings to this location headers depending on the Location the ProxyPass request is made.