mirror of
https://github.com/nsupdate-info/nsupdate.info.git
synced 2026-04-25 08:35:56 +03:00
[GH-ISSUE #555] IP detection behing Nginx Proxy Manager running on another machine fails #382
Labels
No labels
bug
bug
duplicate
easy
easy
enhancement
enhancement
invalid
needs help
pull-request
scalability
security
task
urgent
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/nsupdate.info-nsupdate-info#382
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @gabviv73 on GitHub (Jun 19, 2024).
Original GitHub issue: https://github.com/nsupdate-info/nsupdate.info/issues/555
I'm building a docker container for nsupdate.info.
The web gui and the updates are working, but the IP detection fails: it detects the IP address of the nginx reverse proxy.
What could I do to investigate the issue ?
@ThomasWaldmann commented on GitHub (Jun 19, 2024):
There are 2 ways to solve this:
@gabviv73 commented on GitHub (Jun 20, 2024):
I have simplified my test environment to ease investigation. Now the docker containers are running on a machine with public IP Address.
The Nginx reverse proxy running on container A with IP address 192.168.48.2 seems to set the correct headers:
socat -v TCP-LISTEN:8916 STDOUTThe gunicorn server running nsupdate.info on conatiner B with IP Address 192.168.0.2 is started with:
gunicorn --workers=4 --log-level=info --forwarded-allow-ips='*' --bind 0.0.0.0:8000 nsupdate.wsgiBut nsupdate.info detects the IP address of the docker host interface 192.168.0.1:
nsupdate.info | [2024-06-20 19:26:13,045] DEBUG ajax_get_ips response: {'ipv4': '192.168.0.1', 'ipv4_rdns': '', 'ipv6': '', 'ipv6_rdns': ''} [ip: 192.168.0.1, ua: "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0"]It seems that gunicorn discards the headers ...
@gabviv73 commented on GitHub (Jun 21, 2024):
I came to a solution after a bit of research.
It seems that django does know anything about X-Forwarede headers things.
I've installed and configured a middleware, and now it works:
pip install django-xffactivated the middleware in
local_settings.pyMIDDLEWARE = MIDDLEWARE + ('xff.middleware.XForwardedForMiddleware',)Now the X-Forwarded IP is correctly red.
See here
@ThomasWaldmann commented on GitHub (Jun 21, 2024):
I don't think I've ever used / needed that middleware.
@gabviv73 commented on GitHub (Jun 24, 2024):
Maybe you are using Nginx or Apache with wsgi modules to serve the app.
Using gunicorn, it's necessary. Have a look at my PR for the docker container.
@tsz-systems commented on GitHub (Aug 1, 2024):
Did you manage to get both IPv4 and IPv6 working with your setup?
Both ipv4.example.com and ipv6.example.com return my ipv6 address.
When I curl -4 it returns my v4 address.
My setup is also nginxproxymanager -> nsupdate (dockerized)
@gabviv73 commented on GitHub (Aug 2, 2024):
Hy, sorry, I can't test IPv6 on my setup.
@tsz-systems commented on GitHub (Aug 5, 2024):
I found my mistake. It wasn’t related to my compose stack…
In my DNS, I had set a CNAME for the wildcard domain which returned both v4 and v6.
After fixing this, the “distinction” between v4 and v6 requests now works.
… that’s what comes from lack of sleep.