X-Forwarded-For on Ubuntu 24.04 Noble

Support for the Debian/Ubuntu package, created by JCFP.
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
simulacrum
Newbie
Newbie
Posts: 3
Joined: October 20th, 2026, 12:32 am

X-Forwarded-For on Ubuntu 24.04 Noble

Post by simulacrum »

This is a quick bug report for the sabnzd 5.2.0~beta2-0ubuntu1~jcfp1~24.04 deb package on 24.04:

With verify_xff_header on and nginx setting X-Forwarded-For, every proxied request fails with “X-Forwarded-For received from 127.0.0.1, which is not in xff_trusted_hosts”.

According to the llm the root cause is uvicorn < 0.38 does exact string membership in ProxyHeadersMiddleware; SABnzbd passes CIDR strings (127.0.0.0/8, 127.0.0.1/32). uvicorn 0.38.0 introduced _TrustedHosts with ip_network containment.
User avatar
sander
Release Testers
Release Testers
Posts: 9510
Joined: January 22nd, 2008, 2:22 pm

Re: X-Forwarded-For on Ubuntu 24.04 Noble

Post by sander »

I know little about nginx and xff, but it just works on my setup (Ubuntu 26.04, SABnzbd from PPA, uvicorn 0.38.0 (I think: that's the system wide version), plain base sabnzbd.ini (nothin set, just one newsserver), with url_base = /sabnzbd in sabnzbd.ini

So ... what's different?

Code: Select all

2026-10-20 11:56:21,728::DEBUG::[interface:2403] Request GET /sabnzbd/ from 127.0.0.1:0 (X-Forwarded-For: 127.0.0.1) [Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36] {}

2026-10-20 11:56:31,242::DEBUG::[interface:2403] Request GET /sabnzbd/ from 192.168.1.235:0 (X-Forwarded-For: 192.168.1.235) (via 127.0.0.1) [Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36] {}

2026-10-20 11:59:49,786::DEBUG::[interface:2403] Request GET /sabnzbd/ from 192.168.1.235:0 (X-Forwarded-For: 192.168.1.235) (via 127.0.0.1) [curl/8.18.0] {}

2026-10-20 12:25:28,378::DEBUG::[interface:2403] Request POST /sabnzbd/api from 192.168.1.237:0 (X-Forwarded-For: 192.168.1.237) (via 127.0.0.1) [Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36] {'mode': 'queue', 'start': '0', 'limit': '20', 'output': 'json'}


2026-10-20 12:26:00,927::DEBUG::[interface:2403] Request GET /sabnzbd/ from [::1]:0 (X-Forwarded-For: ::1) (via 127.0.0.1) [curl/8.18.0] {}

With nginx config:

Code: Select all

# http://<host>:9999/sabnzbd/ -> SABnzbd on 127.0.0.1:8080/sabnzbd/
# Requires SABnzbd url_base = /sabnzbd, so paths pass through unchanged.

server {
    listen 9999;
    listen [::]:9999;

    location /sabnzbd {
        # No URI part on proxy_pass: the request path is forwarded as-is
        proxy_pass http://127.0.0.1:8080;

        proxy_set_header Host $http_host;
        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;

        # NZB uploads
        client_max_body_size 100m;
    }
}
simulacrum
Newbie
Newbie
Posts: 3
Joined: October 20th, 2026, 12:32 am

Re: X-Forwarded-For on Ubuntu 24.04 Noble

Post by simulacrum »

Yeah, I should have been clearer: this only affects Ubuntu 24.04 and earlier. It won't affect Ubuntu 26.04 because the system python-uvicorn is v0.38 and that version works fine. In Ubuntu 24.04 the system python-uvicorn (that sab depends on) is v0.24 (or similar) and it doesn't work the way sab expects.
Last edited by simulacrum on October 21st, 2026, 3:18 am, edited 1 time in total.
User avatar
jcfp
Release Testers
Release Testers
Posts: 1036
Joined: February 7th, 2008, 12:45 pm

Re: X-Forwarded-For on Ubuntu 24.04 Noble

Post by jcfp »

Thanks for bringing this to our attention. Uvicorn release notes indicate support for passing networks as trusted hosts was introduced in 0.31.0, which is indeed newer than the version available in noble/24.04 (0.27.1). Unfortunately, uvicorn >=0.35.0 seem to require a newer websockets than available in noble, so backporting 0.38.0 from Ubuntu resolute/26.04 would mean extra work; I'll try a backport of uvicorn 0.32.0 from Debian trixie first.
simulacrum
Newbie
Newbie
Posts: 3
Joined: October 20th, 2026, 12:32 am

Re: X-Forwarded-For on Ubuntu 24.04 Noble

Post by simulacrum »

jcfp wrote: October 21st, 2026, 3:16 am Thanks for bringing this to our attention. Uvicorn release notes indicate support for passing networks as trusted hosts was introduced in 0.31.0, which is indeed newer than the version available in noble/24.04 (0.27.1). Unfortunately, uvicorn >=0.35.0 seem to require a newer websockets than available in noble, so backporting 0.38.0 from Ubuntu resolute/26.04 would mean extra work; I'll try a backport of uvicorn 0.32.0 from Debian trixie first.
Thanks! And thanks for all your work keeping the PPA going all these years!
User avatar
jcfp
Release Testers
Release Testers
Posts: 1036
Joined: February 7th, 2008, 12:45 pm

Re: X-Forwarded-For on Ubuntu 24.04 Noble

Post by jcfp »

You're welcome. Let me know if the uvicorn update fixes the problem, I don't have a reverse proxy setup to test this locally.
User avatar
sander
Release Testers
Release Testers
Posts: 9510
Joined: January 22nd, 2008, 2:22 pm

Re: X-Forwarded-For on Ubuntu 24.04 Noble

Post by sander »

simulacrum wrote: October 21st, 2026, 1:39 am Yeah, I should have been clearer: this only affects Ubuntu 24.04 and earlier. It won't affect Ubuntu 26.04 because the system python-uvicorn is v0.38 and that version works fine. In Ubuntu 24.04 the system python-uvicorn (that sab depends on) is v0.24 (or similar) and it doesn't work the way sab expects.
Ah, now I understand it. And now I understand your OP:
it does work with uvicorn 0.31 and higher (as on Ubuntu 26.04: 0.38)
it does not work uvicorn <0.31 (as on Ubuntu 24.04)


Sorry for my confusion.

Ubuntu 24.04 LTS (Noble) ships uvicorn 0.27.1
Ubuntu 26.04 LTS (Resolute) ships uvicorn 0.38.0.
User avatar
sander
Release Testers
Release Testers
Posts: 9510
Joined: January 22nd, 2008, 2:22 pm

Re: X-Forwarded-For on Ubuntu 24.04 Noble

Post by sander »

Oh, time to plug my AppImage solution: https://github.com/sanderjo/sabnzbd-AppImage ... one file that contains all. No dependencies, thus should work on Ubuntu 24.04 and older. And on any Linux x86_64.

Other alternatives: from source, snap, flatpak, docker.
Post Reply