meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
sw:apache:proxy [2025/01/11 10:48] – created niziaksw:apache:proxy [2025/05/29 10:49] (current) niziak
Line 1: Line 1:
 ====== reverse proxy ====== ====== reverse proxy ======
 +
 +===== log x-forwarded-for =====
 +
 +From apache2.conf:
 +<code>
 +https://hub.docker.com/_/php
 +# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
 +# Use mod_remoteip instead.
 +</code>
 +
 +==== enable remoteip module ====
 +
 +Enable the remoteip module:
 +
 +<code bash>sudo a2enmod remoteip</code>
 +
 +<file ini /etc/apache2/conf-available/remoteip.conf>
 +RemoteIPHeader X-Forwarded-For
 +RemoteIPTrustedProxy 192.168.0.0/16
 +</file>
 +
 +<code bash>sudo a2enconf remoteip</code>
 +
 +
 +===== reverse proxy =====
 +
 +<code>
 +ProxyRequests Off
 +SSLEngine On
 +SSLProxyEngine On
 +
 +ProxyPass / https://example.com/    <-- note trailing slash!
 +ProxyPassReverse / https://example.com/    <-- note trailing slash!
 +</code>
 +
  
 ===== app behind location (folder) ===== ===== app behind location (folder) =====
Line 14: Line 49:
  
 If not possibe to reconfigure remote service server you can try to use ''proxy_html'' module which can rewrite content and fix URL mappings. 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: [[http://www.apachetutor.org/admin/reverseproxies|Running a Reverse Proxy in Apache]]
  
 <code bash> <code bash>
Line 19: Line 56:
 </code> </code>
  
 +File ''/etc/apache2/mods-available/proxy_html.conf'' contains example:
 +<code ini>
 +# 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>
 +
 +</code>