My ERPNext is running behind an nginx reverse proxy and it is working just fine. However, I would like to restrict the IP addresses that can access the system. Yet when I look at any of the security settings of the users, the last IP address is always that of the reverse proxy.
The nginx config is forwarding the IP address, yet ERPNext does not seem to trust the X-Forwarded-For or X-Real-IP headers being forwarded. Is there a way to change that?
location / {
proxy_pass http://192.168.7.28:80;
proxy_redirect off;
# Improved IP forwarding headers
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header Host $host;
proxy_set_header Range $http_range;
proxy_set_header If-Range $http_if_range;
add_header X-Frame-Options SAMEORIGIN;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
client_max_body_size 512M;
}
And is there a way to set ERPNext to only trust the X-Forwarded-For header when the request comes from the trusted nginx proxy?