skip to Main Content

I’m new on apache reverse proxy, and I trying to reverse Url calling like bellow:

enter image description here

I’m able to forward all request on Webserver1 like that:

 <VirtualHost *:80>  

 ProxyPreserveHost On  
 ServerName localhost  
 ProxyPass / http://webserver1/  
 ProxyPassReverse / http://webserver1/  
 </VirtualHost>  

But I’m not able to make condition on Url Param example:

If "http://reverse.proxy.com/?param=foo" then forwarding it to WebServer 2

And also, I don’t know if those rules could be on the Same configuration.

Many thanks for your help

2

Answers


  1. Chosen as BEST ANSWER

    Finally, I found the solution to do like that.

    <VirtualHost *:80>
    
    ProxyPreserveHost On
    ServerName localhost
    
    RewriteEngine on
    logLevel warn rewrite:trace3
    
    RewriteCond %{REQUEST_URI} ^/ [NC]
    RewriteCond %{QUERY_STRING} ^param=(.*)
    RewriteRule (.*) http://Webserver2/?param=%1? [P]
    
    ProxyPassMatch / http://Webserver1
    ProxyPassReverse / http://Webserver1
    
    </VirtualHost>
    

    it seems working fine


  2. You should try this once..

    <VirtualHost *:80>
    ServerName localhost
    RewriteEngine on
    ProxyPass / http://webserver1/
    ProxyPassReverse / http://webserver1/
    RewriteRule "^/foo.html$" "bar.html" [R]

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search