Allow use of X-Forwarded-For [$5 awarded] #107

Closed
opened 2026-10-05 03:59:13 +02:00 by adam · 14 comments
Owner

Adding the X-Forwarded-For header would allow any instance of ZNC behind a reverse-proxy to set proper IPs for a cookie, and show the proper IP in webadmin.

Also, an allowed-proxies config variable should be added, as a white-list to prevent abuse.


The $5 bounty on this issue has been claimed at Bountysource.

Adding the X-Forwarded-For header would allow any instance of ZNC behind a reverse-proxy to set proper IPs for a cookie, and show the proper IP in webadmin. Also, an `allowed-proxies` config variable should be added, as a white-list to prevent abuse. ## <bountysource-plugin> --- The **[$5 bounty](https://www.bountysource.com/issues/663-allow-use-of-x-forwarded-for?utm_campaign=plugin&utm_content=tracker%2F1759&utm_medium=issues&utm_source=github)** on this issue has been claimed at [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1759&utm_medium=issues&utm_source=github). </bountysource-plugin> <!-- github-sync-id:4526196 -->
adam closed this issue 2026-10-05 03:59:13 +02:00
Author
Owner

What bug with session cookies?

What bug with session cookies? <!-- github-comment-id:5643310 -->
Author
Owner

Whenever more than five or so users use webadmin at once, I tend to get "Invaild Session for your IP" errors.

Whenever more than five or so users use webadmin at once, I tend to get "Invaild Session for your IP" errors. <!-- github-comment-id:5644236 -->
Author
Owner

It's not related to number of users... Each session stores your IP, from which you created that session.
If you try to use another IP with existing session, you get that error. Do you change your IP? Maybe you change your proxies?
You can turn that protection off in global settings of webadmin, but that would decrease security.

It's not related to number of users... Each session stores your IP, from which you created that session. If you try to use another IP with existing session, you get that error. Do you change your IP? Maybe you change your proxies? You can turn that protection off in global settings of webadmin, but that would decrease security. <!-- github-comment-id:5644867 -->
Author
Owner

I see, that's odd.

I see, that's odd. <!-- github-comment-id:5654028 -->
Author
Owner

I think what @neersighted is saying, is that he is putting his ZNC behind a reverse proxy. So all the clients are coming from the IP of the proxy. Proxies usually set X-Forwarded headers indicating the real IP/protocol etc.

This sounds like a feature request for an option to follow these headers.

x-forwarded-proto: https
x-forwarded-port: 443
x-forwarded-for: 172.16.0.241
I think what @neersighted is saying, is that he is putting his ZNC behind a reverse proxy. So all the clients are coming from the IP of the proxy. Proxies usually set X-Forwarded headers indicating the real IP/protocol etc. This sounds like a feature request for an option to follow these headers. ``` x-forwarded-proto: https x-forwarded-port: 443 x-forwarded-for: 172.16.0.241 ``` <!-- github-comment-id:5678151 -->
Author
Owner

Yes, that's what I meant.

Yes, that's what I meant. <!-- github-comment-id:5679898 -->
Author
Owner

bump.

bump. <!-- github-comment-id:6790890 -->
Author
Owner

bump +1 for this proxying stuff like this down with apache is common stuff and should work

bump +1 for this proxying stuff like this down with apache is common stuff and should work <!-- github-comment-id:8091854 -->
Author
Owner

Also, nginx usually uses X-Real-IP, or X-Forwarded-For, so both should be supported.

Also, nginx usually uses `X-Real-IP`, or `X-Forwarded-For`, so both should be supported. <!-- github-comment-id:8096283 -->
Author
Owner

The latest nginx configs you cen get from the wiki contain both headers in the include file that's used.

The latest nginx configs you cen get from the wiki contain both headers in the include file that's used. <!-- github-comment-id:8097531 -->
Author
Owner

I have tried this patch https://github.com/MartinMartimeo/znc/commit/44be37a33e0df7df00cd09b2a1d9ff15c0599780 on the latest znc git version (at the time of this writing) and it works perfectly.

I have tried this patch https://github.com/MartinMartimeo/znc/commit/44be37a33e0df7df00cd09b2a1d9ff15c0599780 on the latest znc git version (at the time of this writing) and it works perfectly. <!-- github-comment-id:9666201 -->
Author
Owner

Please implement this!

Please implement this! <!-- github-comment-id:11394579 -->
Author
Owner
Someone should fix https://github.com/MartinMartimeo/znc/commit/44be37a33e0df7df00cd09b2a1d9ff15c0599780 up <!-- github-comment-id:16287536 -->
Author
Owner

This is implemented in #349

This is implemented in #349 <!-- github-comment-id:40867655 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#107