Case:
User requests https://api.abc.com
This is reverse proxied (Apache 2.2) to an internal server server at http://internal.abc.com:123
As per Retain original request URL on mod_proxy redirect , by adding:
ProxyPreserveHost On
to httpd.conf, internal.abc.com currently recognizes the original request url as:
http://api.abc.com:123
Is there any way for me to recover the original URL of https://api.abc.com ? That is, to also retain the original protocol (http) and port (80, or empty is also fine)
The "ProxyPass" and "ProxyPassReverse" parameters are used to tell Apache how to proxy requests. They require the "mod_proxy.so" and "mod_proxy_http.so" Apache modules, which are loaded by default in RHEL5 and RHEL6, but check the following lines are uncommented in the "/etc/httpd/conf/httpd. conf" file to make sure.
The ProxyPassReverse is used to change the headers sent to Apache from a proxied app server, before Apache sends it to the browser.
mod_proxy is an optional module for the Apache HTTP Server. This module implements a proxy, gateway or cache for Apache. It implements proxying capability for AJP13 (Apache JServ Protocol version 1.3), FTP, CONNECT (for SSL), HTTP/0.9, HTTP/1.0, and (since Apache 1.3. 23) HTTP/1.1.
When you send a web request, your request goes to the proxy server first. The proxy server then makes your web request on your behalf, collects the response from the web server, and forwards you the web page data so you can see the page in your browser.
You need this parameter RequestHeader set X-Forwarded-Proto "https"
, without this, the returned location will be http://api.abc.com
.
ProxyRequests Off
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto "https"
ProxyPass / http://internal.abc.com:123
ProxyPassReverse / http://internal.abc.com:123
With this configuration, both queries (from lan
and wan
) will work fine:
https://api.abc.com
http://internal.abc.com:123
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With