I want to map multiple customer facing URLs to a single internal end-point, but with a query parameter to to identify each customer.
For example customer enters https://external_host/customer1
I want a reverse proxy to forward it as https://internal_host/app?customer=cust1
I have tried the following:
<Location "/customer1" >
RewriteEngine On
RewriteRule /customer1 /customer1?customer=cust1 [QSA,P]
ProxyPass https://<internal host>/app
ProxyPassreverse https://<internal host>/app
</Location>
<Location "/customer2" >
RewriteEngine On
RewriteRule /customer2 /customer2?customer=cust2 [QSA,P]
ProxyPass https://<internal host>/app
ProxyPassreverse https://<internal host>/app
</Location>
The basic proxy works, in that the request is forwarded to the internal server, but the query parameter is not added.
From all the reading I have done, I feel it should be possible to do what I want, but cannot get it to work.
Any pointers gratefully received.
Regards
Chris
2
Answers
I solved this as follows:
Chris
The
ProxyPass
andProxyPassReverse
from the question config are ignored, because theP
in[QSA,P]
performs the proxy request.Some additional cases to add query parameter
extraparam=something
to the proxied server:Regular expression and remote server
if you need to use a regular expression in your rule (first wildcard
(.*)
is replaced by$1
):If the proxied server uses https, you should add
SSLProxyEngine On
to the configuration: