meta data for this page
reverse proxy
log x-forwarded-for
From apache2.conf:
https://hub.docker.com/_/php # Note that the use of %{X-Forwarded-For}i instead of %h is not recommended. # Use mod_remoteip instead.
enable remoteip module
Enable the remoteip module:
sudo a2enmod remoteip
- /etc/apache2/conf-available/remoteip.conf
RemoteIPHeader X-Forwarded-For RemoteIPTrustedProxy 192.168.0.0/16
sudo a2enconf remoteip
reverse proxy
ProxyRequests Off SSLEngine On SSLProxyEngine On ProxyPass / https://example.com/ <-- note trailing slash! ProxyPassReverse / https://example.com/ <-- note trailing slash!
app behind location (folder)
To achieve:
It is complicated. Needs rewriting of content body and fix all links to local resources. It is better to make 1:1 reverse proxy and configre remote service to work under location (folder):
If not possibe to reconfigure remote service server you can try to use proxy_html
module which can rewrite content and fix URL mappings.
Read: Running a Reverse Proxy in Apache
a2enmod proxy_html
File /etc/apache2/mods-available/proxy_html.conf
contains example:
# ProxyRequests Off <-- this is an important security setting # ProxyPass /my-gateway/ http://some.app.intranet/ # <Location /my-gateway/> # ProxyPassReverse / # ProxyHTMLEnable On # ProxyHTMLURLMap http://some.app.intranet/ /my-gateway/ # ProxyHTMLURLMap / /my-gateway/ # </Location>