Skip to content

Need a way to set the trustProxy setting for reverse proxies #859

@rob4226

Description

@rob4226

⚠️ Please verify that this bug has NOT been reported before.

  • I checked and didn't find similar issue

🛡️ Security Policy

Description

Unless I missed it somewhere, there doesn't seem to be a way to set the trustProxy setting. Per the below source code:

if (await Settings.get("trustProxy")) {
const forwardedFor = socket.client.conn.request.headers["x-forwarded-for"];
if (typeof forwardedFor === "string") {
return forwardedFor.split(",")[0].trim();
} else if (typeof socket.client.conn.request.headers["x-real-ip"] === "string") {
return socket.client.conn.request.headers["x-real-ip"];
}
}
return clientIP.replace(/^::ffff:/, "");
}

if the trustProxy setting is not set, the X-Forwarded-For and X-Real-Ip headers will not be respected which is needed when a reverse proxy is used.

I set the trustProxy setting in the Sqlite3 database manually and the real IP's were used correctly so just a way to set the trustProxy setting with an environment variable and/or a setting in the web UI is needed.

INSERT INTO setting (key,value,type) VALUES('trustProxy', 'true', 'general');

👟 Reproduction steps

Use a reverse proxy and login into Dockage and the logs will report the private IP address of the Docker container instead of the real IP address of the user.

👀 Expected behavior

A way to set the trustProxy setting with an environment variable and/or a setting in the web UI so that the X-Forwarded-For and X-Real-Ip headers will be respected when using a reverse proxy.

😓 Actual Behavior

The private IP address 172.19.0.1 of the docker container is reported instead of the real IP:

dockge-1  | 2025-09-26T21:09:24Z [AUTH] INFO: Origin is not set, IP: ::ffff:172.19.0.1
dockge-1  | 2025-09-26T21:09:24Z [SERVER] INFO: Socket connected (direct)
dockge-1  | 2025-09-26T21:09:24Z [SERVER] INFO: Redirect to setup page
dockge-1  | 2025-09-26T21:10:15Z [AUTH] INFO: Login by username + password. IP=172.19.0.1
dockge-1  | 2025-09-26T21:10:15Z [RATE-LIMIT] INFO: remaining requests: 19
dockge-1  | 2025-09-26T21:10:15Z [AUTH] INFO: Successfully logged in user MyUsername99. IP=172.19.0.1

Dockge Version

1.5.0

💻 Operating System and Arch

Ubuntu Server 25.04

🌐 Browser

Google Chrome 140.0.7339.208

🐋 Docker Version

Docker version 28.4.0, build d8eb465

🟩 NodeJS Version

No response

📝 Relevant log output

dockge-1  | 2025-09-26T21:09:24Z [AUTH] INFO: Origin is not set, IP: ::ffff:172.19.0.1
dockge-1  | 2025-09-26T21:09:24Z [SERVER] INFO: Socket connected (direct)
dockge-1  | 2025-09-26T21:09:24Z [SERVER] INFO: Redirect to setup page
dockge-1  | 2025-09-26T21:10:15Z [AUTH] INFO: Login by username + password. IP=172.19.0.1
dockge-1  | 2025-09-26T21:10:15Z [RATE-LIMIT] INFO: remaining requests: 19
dockge-1  | 2025-09-26T21:10:15Z [AUTH] INFO: Successfully logged in user MyUsername99. IP=172.19.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions