Conditional ProxyPass Apache

谁都会走 提交于 2019-12-11 18:54:03

问题


I'm trying to achieve a conditional proxypass directive, so when a certain query string is being called to the virtualhost it proxies it somewhere else and adds Header.

However ProxyPass is not allowed within the if directive.

I was trying this:

VirtualHost <*:443>
ServerName "${APACHE_HOSTNAME}"
<If "%{QUERY_STRING} =~ /some_string/">
RequestHeader set "some_string" "some_string"
Header set "some_string" "some_string"
ProxyPass / https://<domain>/
ProxyPassReverse /  https://<domain>/
</If>
</VirtualHost>

Is there any other way arround of this ? Some Virtualhost logic or using re-writes ?

Thanks !


回答1:


ok this worked for me:

<Location "/path_uri">
RewriteEngine on
RewriteCond %{QUERY_STRING} ^<query_string> [NC]
RequestHeader set "header" "header"
RewriteRule ^/(.*) https://URL/ [QSA,P,L]
ProxyPassReverse https://URL/
</Location>


来源:https://stackoverflow.com/questions/50874367/conditional-proxypass-apache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!