Proxy apache中的条件反向代理
如果请求来自公共ip 50.12.95.78。代理传递到url 如果请求来自其他公共ip。代理传递到urlProxy apache中的条件反向代理,proxy,conditional,reverse,Proxy,Conditional,Reverse,如果请求来自公共ip 50.12.95.78。代理传递到url 如果请求来自其他公共ip。代理传递到url apache中的设置是什么?反向代理无法在if条件下工作。您可以使用mod_proxy和mod_rewrite在Apache httpd中设置条件反向代理 例如,如果您最初使用以下配置设置了反向代理: ProxyPass / http://192.168.1.100/ ProxyPassReverse / http://192.168.1.100/ 可以通过使用使其有条件。
apache中的设置是什么?反向代理无法在if条件下工作。您可以使用
mod_proxy
和mod_rewrite
在Apache httpd中设置条件反向代理
例如,如果您最初使用以下配置设置了反向代理:
ProxyPass / http://192.168.1.100/
ProxyPassReverse / http://192.168.1.100/
可以通过使用使其有条件。示例配置可能如下所示:
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
重写规则
RewriteCond
指令匹配,即如果远程IP
地址是50.12.95.78。
- [P]roxy标志还阻止进一步应用
指令重写规则
- 环境变量proxy_pass_path设置为告诉
指令该路径已被修改ProxyPathReverse
重写规则
如果第一个未计算,则自动应用ProxyPathReverse
指令被修改为重写响应头
基于proxy\u pass\u path变量超出了问题的范围,请记住,这种代理不会实现任何真正形式的安全性。50.12.95.78以外的IP地址仍可访问
http://192.168.1.100/quote
只需请求http:///quote
为供将来参考,在