Conditional ProxyPass Apache

2019-09-02 05:26发布

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条回答
一纸荒年 Trace。
2楼-- · 2019-09-02 05:58

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>
查看更多
登录 后发表回答