Перейти к основному контенту

Configuring Correct User IP Display When Using HAProxy Authentication

When using a load balancer such as HAProxy, all users in the system see the HAProxy address instead of the actual IP address of the user's workstation.

Solution:

  1. Add the following line to the HAProxy configuration file in the backend jms-web section:

backend jms-web
  mode http
  option forwardfor except 127.0.0.1 
  http-request set-header X-Forwarded-For %[src]
  1. On each JS server, open the Nginx configuration file:

nano /opt/jumpserver/config/nginx/lb_http_server.conf
And add the following lines so that the final result looks like this:
server {
  listen 443 ssl http2;
  set_real_ip_from 10.10.53.210;  # IP вашего HAProxy
  real_ip_header X-Forwarded-For;
  real_ip_recursive on;

  server_tokens off;
  1. Restart HAProxy and Jumpserver.

systemctl restart haproxy
jmsctl restart