0

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

Principe-forwarding-schema.jpg

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

Loudone
  • 103
  • 2

1 Answers1

0

For conditionals like you describe you have to use mod_rewrite to proxy.

RewriteCond %{QUERY_STRING} ^param=foo$
RewriteRule ^(.*) http://webserver2/$1 [P,L]
RewriteRule ^(.*) http://webserver1/$1 [P,L]

Explanation: First we check for the query string you want to match, if it matches the following RewriteRule is applied, but if it doesn't match the second RewriteRule will apply.

Daniel Ferradal
  • 2,415
  • 1
  • 8
  • 13