Retaining protocol and port number from reverse proxy request

apache, apache2, httpd.conf, mod-proxy, reverse-proxy

Solution

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

Problem

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)

Original source

Related problems