Differences

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

Link to this comparison view

documentation:2.1:behindproxyminihowto [2019/10/08 14:09] (current)
coudot created
Line 1: Line 1:
 +====== Running LemonLDAP::​NG behind a reverse proxy ======
 +
 +Your network infrastructure might require that LemonLDAP::​NG components (Portal, Manager, Handler) run behind a reverse proxy.
 +
 +{{ :​documentation:​reverseproxy.png?​nolink |}}
 +
 +
 +In this case, LemonLDAP::​NG components will store the ip address of the connection between the reverse proxy and the webserver in the session, and in logs. This prevents features such as session restrictions and rules based on `ipAddr` from working as expected.
 +
 +A Content Delivery Network (CDN) would also have the same issue.
 +
 +In order to make LemonLDAP::​NG behave correctly behind a proxy, you need to forward the original IP address all the way to LemonLDAP::​NG.
 +
 +In order to do this you have several options.
 +
 +===== HTTP Header =====
 +
 +This generic method is the most likely to work in your particular environment.
 +
 +First, configure your reverse proxy (or CDN) to send the origin IP address in a HTTP header. Most reverse proxies do this by default, generally in a header named ''​X-Forwarded-For''​ or ''​X-Real-IP''​.
 +
 +Once the header is transmitted to LemonLDAP::​NG'​s web server, you may uncomment the relevant parts of the configuration file.
 +
 +  * For Nginx:
 +<file nginx>
 +    set_real_ip_from ​ 127.0.0.1;
 +    real_ip_header ​   X-Forwarded-For;​
 +</​file>​
 +<note tip>Make sure Nginx was compiled with the [[http://​nginx.org/​en/​docs/​http/​ngx_http_realip_module.html|http_real_ip module]]</​note>​
 +
 +  * For Apache:
 +<file apache>
 +     ​RemoteIPHeader X-Forwarded-For
 +     ​RemoteIPInternalProxy 127.0.0.1
 +</​file>​
 +<note tip>Make sure the [[https://​httpd.apache.org/​docs/​2.4/​mod/​mod_remoteip.html|mod_remoteip module]] is enabled in your Apache installation</​note>​
 +
 +<note warning>​Both modules need you to specify the address of your reverse proxy. Using the ''​http_real_ip''​ or ''​mod_remoteip''​ module might let an attacker impersonate any IP address they want by setting the ''​X-Forwarded-For''​ header themselves. Please read the relevant module documentation carefully.</​note>​
 +
 +
 +===== PROXY Protocol =====
 +
 +Alternatively,​ if your proxy supports the PROXY protocol (Nginx, HAProxy, Amazon ELB), you may use it to carry over the information almost transparently.
 +
 +Refer to your reverse proxy'​s documentation to find out how to enable the PROXY protocol on the reverse proxy side.
 +
 +Then, on the LemonLDAP::​NG side, in the NGINX configuration of your Portal/​Manager/​Handler:​
 +
 +<file nginx>
 + ​listen 80   ​proxy_protocol;​
 +# or
 +# listen 443 ssl proxy_protocol;​
 +</​file>​
 +