skip to Main Content

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


  1. Chosen as BEST ANSWER

    I solved this as follows:

    ProxyRequests off
    ProxyPass /app http://<internal server>/app
    ProxyPassReverse /app http://<internal server>/app
    
    RewriteEngine on
    RewriteRule ^/cust1.htm /app?client=cust1.htm [QSA,P]
    RewriteRule ^/cust2.htm /app?client=cust2.htm [QSA,P]
    

    Chris


  2. The ProxyPass and ProxyPassReverse from the question config are ignored, because the P 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):

    RewriteEngine on
    RewriteRule ^/path/to/hook/to/proxy/(.*) http://example.org/$1?extraparam=something [QSA,P]
    

    If the proxied server uses https, you should add SSLProxyEngine On to the configuration:

    RewriteEngine on
    SSLProxyEngine on
    RewriteRule ^/path/to/hook/to/proxy/(.*) https://example.org/$1?extraparam=something [QSA,P]
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search