Reputation: 73
if request comes from public ip 50.12.95.78. Proxypass to http://192.168.1.100/quote url.
if request comes from other public ip . Proxypass to http://192.168.1.100/ url
What is the settings for it in apache? Reverse proxy wont work in if condition.
Upvotes: 0
Views: 3181
Reputation: 36
You can set up a conditional reverse proxy in Apache httpd by utilizing mod_proxy
and mod_rewrite
.
For instance, if you originally had your reverse proxy set up with the following configuration:
ProxyPass / http://192.168.1.100/
ProxyPassReverse / http://192.168.1.100/
It can be made conditional by using the proxy flag on a RewriteRule. An example configuration could look like this:
RewriteEngine On
ProxyPassInterpolateEnv On
RewriteCond "%{REMOTE_ADDR}" =50.12.95.78
RewriteRule (.*) http://192.168.1.100/quote$1 [P,E=proxy_pass_path:/quote]
RewriteRule (.*) http://192.168.1.100$1 [P]
ProxyPassReverse / http://192.168.1.100${proxy_pass_path}/ interpolate
RewriteRule
is applied and proxied only if the preceding
RewriteCond
directive is matched, i.e. if the Remote IP
Address is 50.12.95.78.
RewriteRule
directives from being applied.ProxyPathReverse
directive that the path has been modified.RewriteRule
is automatically applied if the first did not evaluate.ProxyPathReverse
directive is modified to rewrite response headers
based on the proxy_pass_path variable.Going beyond the scope of your question, bear in mind that this kind of proxy will not implement any real form of security. IP addresses other than 50.12.95.78 will still be able to access http://192.168.1.100/quote
simply by requesting http://<Proxy_Host>/quote
.
Upvotes: 2