Using traefik with frappe docker, user login is capturing Traefik's internal ip address

I’m a noob when it comes to server administration and devops. I have followed the single server example from frappe docker single server guide

So far I’ve managed to get everything working, but whenever a user login, the system is capturing traefik’s internal ip address instead of the user’s actual ip address, so in the activity log all users have the same ip address, which is traefik’s internal ip address. Which setting do I need to change, cause I’m pretty sure there must be a setting for it.

Thanks in advance.

1 Like

Try setting nginx env var for frontend container. UPSTREAM_REAL_IP_HEADER. frappe_docker/docs/environment-variables.md at main · frappe/frappe_docker · GitHub

1 Like

For anyone facing the same issue in the future, this is what I did. In my project’s .env file, I made the following changes:

UPSTREAM_REAL_IP_ADDRESS: {Traefik’s internal IP}
UPSTREAM_REAL_IP_HEADER: X-Forwarded-For
UPSTREAM_REAL_IP_RECURSIVE: “on”

Regenerate the .yaml file and rerun docker compose up.

2 Likes

PS: Just adding some notes


Before Initial Deployment

Add the following environment variables to your ERPNext Docker setup:

UPSTREAM_REAL_IP_ADDRESS=<traefik_or_docker_gateway_ip>
UPSTREAM_REAL_IP_HEADER=X-Forwarded-For
UPSTREAM_REAL_IP_RECURSIVE=on

Deploy normally.


For Existing Deployment

Step 1: Enter ERPNext Container

docker exec -it <container_name> /bin/bash


Step 2: Edit Nginx Configuration

cd /etc/nginx/conf.d
vim frappe.conf

Add or update the following lines:

set_real_ip_from <traefik_or_docker_gateway_ip>;
real_ip_header X-Forwarded-For;
real_ip_recursive on;

Save and exit:

  • Esc

  • :wq


Step 3: Test and Reload Nginx

nginx -t
nginx -s reload