问题
I am trying to setup a reverse proxy with 2 CentOS 6.5 machines running Apache 2.2.15, where the private URL contains parameters (static, same for all requests coming through the public url), so the setup should work like this:
User --> public.url/ --> private.url/?parameter=value
User --> public.url/anything --> private.url/anything?parameter=value
I have managed to setup the reverse proxy using the following directives in /etc/httpd/conf.d/reverse-proxy.conf
ProxyRequests Off
proxyPass / private.url:80/ connectiontimeout=5 timeout=30
proxyPassReverse / private.url:80/
ProxyPassReverseCookieDomain private.url public.url
<Location />
RequestHeader unset Accept-Encoding
AddOutputFilterByType SUBSTITUTE text/html
Substitute "s|private.url|public.url|i"
</Location>
and everything works as expected:
User --> public.url/ --> private.url/
User --> public.url/anything --> private.url/anything
however I am not sure how to accomplish the addition of the ?parameter=value suffix to the private.url
Any fingers pointing in the right direction will be much appreciated!
回答1:
So I eventually got it to work the way I wanted with mod_rewrite
#Check if string already exists
RewriteCond %{QUERY_STRING} !(.*parameter.*) [NC]
#Add the string and keep hidden from user with [P]
RewriteRule ^/(.*)$ public.url/$1?parameter=value [P]
Hope someone else finds this useful
来源:https://stackoverflow.com/questions/28558357/apache-reverse-proxy-to-url-with-parameters