I need to rewrite a domain name in a query parameter in order to augment a proxy. The proxy basically is just a domain rewrite, but some of the responses from the upstream server include a query parameter that is eventually used as a redirect (in the "Location" header). I need to be able to rewrite this domain name so that it points to the proxy instead of the upstream server. My current config looks like
SSLEngine On
SSLProxyEngine On
# Set the path to SSL certificate
# Usage: SSLCertificateFile /path/to/cert.pem
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
# Servers to proxy the connection, or;
# List of application servers:
# Usage:
# ProxyPass / http://[IP Addr.]:[port]/
# ProxyPassReverse / http://[IP Addr.]:[port]/
# Example:
RewriteEngine On
LogLevel alert rewrite:trace6
RewriteCond %{QUERY_STRING} (.*)upstream\.com(.*)
RewriteRule (.*)upstream\.com(.*) %1proxy.com%2 [N]
ProxyPass / https://upstream.com/
ProxyPassReverse / https://upstream.com/
The proxy is working fine, but one of the first things the upstream server does is send a redirect with a query parameter that is used for a second redirect, which causes the proxy to lose control of the traffic stream. I need this query string rewritten so the upstream servers response will cause a redirect back to the proxy instead of the upstream server.
mod_rewrite is enabled and 'apachectl -t' reports that the config is OK.
Asked by smokes2345
(880 rep)
Nov 17, 2016, 04:54 PM
Last activity: May 12, 2025, 11:07 PM
Last activity: May 12, 2025, 11:07 PM