PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, June 24, 2022

[FIXED] How to reverse on two conditions under an apache reverse proxy

 June 24, 2022     apache, reverse-proxy     No comments   

Issue

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


Solution

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



Answered By - Loudone
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing