Prepare qBittorrent for reverse proxy access

This commit is contained in:
Fabio Scotto di Santolo
2026-10-10 14:05:47 +02:00
parent c8df4dde87
commit 5f3792d603
5 changed files with 131 additions and 6 deletions

View File

@@ -206,7 +206,9 @@ The dotfile vars follow the same split: `desktop_common_dotfiles` carries mode-i
- Atlas qBittorrent is selected by `atlas_manage_qbittorrent` and managed with the - Atlas qBittorrent is selected by `atlas_manage_qbittorrent` and managed with the
`qbittorrent` tag as the admin-owned rootless `atlas-qbittorrent.service` Quadlet. `qbittorrent` tag as the admin-owned rootless `atlas-qbittorrent.service` Quadlet.
Its LAN-only Web UI is `http://192.168.178.55:8090`; configuration lives in Its Web UI is `http://192.168.178.55:8090` on the LAN and prepared for the manual
NPM HTTPS domain `downloads.fscotto.co`, trusting only Aegis for forwarded client
addresses. DNS and NPM configuration stay manual. Configuration lives in
`services/data/qbittorrent`, and only `Archive/Downloads` is writable as payload `services/data/qbittorrent`, and only `Archive/Downloads` is writable as payload
storage. It uses the home Internet connection, not WireGuard or a VPN; no router storage. It uses the home Internet connection, not WireGuard or a VPN; no router
forwarding or published torrent peer port is configured. See `docs/atlas-qbittorrent.md`. forwarding or published torrent peer port is configured. See `docs/atlas-qbittorrent.md`.

View File

@@ -258,6 +258,8 @@ host_enabled_services:
- pmlogger.service - pmlogger.service
- zfs.target - zfs.target
# LAN-only torrent Web UI; downloads use the home Internet connection. # Torrent Web UI: LAN and the existing Aegis gateway for the manual NPM proxy.
atlas_manage_qbittorrent: true atlas_manage_qbittorrent: true
atlas_qbittorrent_image: docker.io/qbittorrentofficial/qbittorrent-nox@sha256:92bfd78d731e254ba64f62b77b0696add6447a33642ee5feda106a26b285aa7f atlas_qbittorrent_image: docker.io/qbittorrentofficial/qbittorrent-nox@sha256:92bfd78d731e254ba64f62b77b0696add6447a33642ee5feda106a26b285aa7f
atlas_qbittorrent_reverse_proxy_enabled: true
atlas_qbittorrent_public_domain: downloads.fscotto.co

View File

@@ -303,3 +303,14 @@ atlas_qbittorrent_image: CHANGEME_PINNED_QBITTORRENT_IMAGE
atlas_qbittorrent_state_dir: "{{ atlas_app_data_mountpoint }}/qbittorrent" atlas_qbittorrent_state_dir: "{{ atlas_app_data_mountpoint }}/qbittorrent"
atlas_qbittorrent_downloads_dir: "{{ atlas_archive_mountpoint }}/Downloads" atlas_qbittorrent_downloads_dir: "{{ atlas_archive_mountpoint }}/Downloads"
atlas_qbittorrent_web_port: 8090 atlas_qbittorrent_web_port: 8090
atlas_qbittorrent_reverse_proxy_enabled: false
atlas_qbittorrent_public_domain: CHANGEME_QBITTORRENT_DOMAIN
atlas_qbittorrent_web_settings:
- {key: 'WebUI\ServerDomains', value: "{{ atlas_qbittorrent_public_domain }}"}
- {key: 'WebUI\ReverseProxySupportEnabled', value: "true"}
- {key: 'WebUI\TrustedReverseProxiesList', value: "{{ atlas_aegis_ip }}"}
- {key: 'WebUI\HostHeaderValidation', value: "true"}
- {key: 'WebUI\CSRFProtection', value: "true"}
- {key: 'WebUI\LocalHostAuth', value: "true"}
- {key: 'WebUI\AuthSubnetWhitelistEnabled', value: "false"}

View File

@@ -101,12 +101,74 @@
mode: "0644" mode: "0644"
register: atlas_qbittorrent_quadlet register: atlas_qbittorrent_quadlet
- name: Reload the user manager after a new or changed Quadlet
become_user: "{{ atlas_admin_username }}"
ansible.builtin.systemd:
scope: user
daemon_reload: true
environment:
XDG_RUNTIME_DIR: "/run/user/{{ atlas_admin_uid }}"
DBUS_SESSION_BUS_ADDRESS: "unix:path=/run/user/{{ atlas_admin_uid }}/bus"
when:
- atlas_qbittorrent_quadlet.changed
- not ansible_check_mode
- name: Manage the declared qBittorrent reverse-proxy settings
when: atlas_qbittorrent_reverse_proxy_enabled | bool
block:
- name: Require a specific public domain and existing Aegis gateway
ansible.builtin.assert:
that:
- atlas_qbittorrent_public_domain is match('^[a-z0-9]+([.-][a-z0-9]+)+$')
- "'CHANGEME' not in atlas_aegis_ip"
- name: Check whether managed Web settings need an update
community.general.ini_file:
path: "{{ atlas_qbittorrent_state_dir }}/qBittorrent/config/qBittorrent.conf"
section: Preferences
option: "{{ item.key }}"
value: "{{ item.value }}"
no_extra_spaces: true
mode: "0600"
loop: "{{ atlas_qbittorrent_web_settings }}"
check_mode: true
register: atlas_qbittorrent_web_probe
no_log: true
diff: false
- name: Stop only qBittorrent before editing its application-managed settings
become_user: "{{ atlas_admin_username }}"
ansible.builtin.systemd:
name: atlas-qbittorrent.service
scope: user
state: stopped
environment:
XDG_RUNTIME_DIR: "/run/user/{{ atlas_admin_uid }}"
DBUS_SESSION_BUS_ADDRESS: "unix:path=/run/user/{{ atlas_admin_uid }}/bus"
when:
- atlas_qbittorrent_web_probe.changed
- not ansible_check_mode
- name: Preserve credentials and change only the declared Web settings
community.general.ini_file:
path: "{{ atlas_qbittorrent_state_dir }}/qBittorrent/config/qBittorrent.conf"
section: Preferences
option: "{{ item.key }}"
value: "{{ item.value }}"
no_extra_spaces: true
owner: "{{ atlas_admin_username }}"
group: "{{ atlas_admin_group }}"
mode: "0600"
loop: "{{ atlas_qbittorrent_web_settings }}"
when: atlas_qbittorrent_web_probe.changed
no_log: true
diff: false
- name: Start qBittorrent and restart only after a Quadlet change - name: Start qBittorrent and restart only after a Quadlet change
become_user: "{{ atlas_admin_username }}" become_user: "{{ atlas_admin_username }}"
ansible.builtin.systemd: ansible.builtin.systemd:
name: atlas-qbittorrent.service name: atlas-qbittorrent.service
scope: user scope: user
daemon_reload: "{{ atlas_qbittorrent_quadlet.changed }}"
state: "{{ 'restarted' if atlas_qbittorrent_quadlet.changed else 'started' }}" state: "{{ 'restarted' if atlas_qbittorrent_quadlet.changed else 'started' }}"
environment: environment:
XDG_RUNTIME_DIR: "/run/user/{{ atlas_admin_uid }}" XDG_RUNTIME_DIR: "/run/user/{{ atlas_admin_uid }}"

View File

@@ -5,7 +5,10 @@ admin-owned rootless `atlas-qbittorrent.service` Quadlet. No VPN is involved:
outbound traffic uses Atlas' normal home-network default route. Existing outbound traffic uses Atlas' normal home-network default route. Existing
WireGuard configuration is unchanged. WireGuard configuration is unchanged.
- LAN Web UI: `http://192.168.178.55:8090` (LAN-only firewalld rule). - LAN Web UI: `http://192.168.178.55:8090` (LAN-only firewalld rule,
already including Aegis at `192.168.178.54`).
- Prepared public domain: `downloads.fscotto.co`, through NPM on Prometheus.
DNS and the NPM Proxy Host remain manual operations.
- Downloads: `/zpool/archive/Downloads`, available through SMB `Archive`. - Downloads: `/zpool/archive/Downloads`, available through SMB `Archive`.
- Private configuration dataset: `zpool/services/data/qbittorrent`. - Private configuration dataset: `zpool/services/data/qbittorrent`.
- Only configuration and Downloads are mounted in the container. - Only configuration and Downloads are mounted in the container.
@@ -13,8 +16,10 @@ WireGuard configuration is unchanged.
published and no router port forwarding is configured. Outbound connections published and no router port forwarding is configured. Outbound connections
work; inbound peer connectivity and seeding are consequently limited. work; inbound peer connectivity and seeding are consequently limited.
- The Web UI keeps authentication and CSRF/Host-header protection enabled. - The Web UI keeps authentication and CSRF/Host-header protection enabled.
Initial settings are seeded only once, preserving passwords and settings Initial settings are seeded only once. Ansible owns only the declared Web
subsequently changed in the application. domain, reverse-proxy support, trusted Aegis source, and authentication/CSRF/Host
protections; it stops only qBittorrent before changing these settings and
preserves credentials and unrelated application settings.
## Deployment ## Deployment
@@ -63,3 +68,46 @@ A real torrent download and a host reboot have not been tested. The initial
WebUI port mapping was corrected to use 8090 internally and externally, preserving WebUI port mapping was corrected to use 8090 internally and externally, preserving
Host-header validation. qBittorrent 5.2 uses `[Network] PortForwardingEnabled=false` Host-header validation. qBittorrent 5.2 uses `[Network] PortForwardingEnabled=false`
for its persistent UPnP/NAT-PMP option. for its persistent UPnP/NAT-PMP option.
## Manual public endpoint setup
Atlas is prepared for `downloads.fscotto.co`, with reverse-proxy support enabled
and only `192.168.178.54` (the Aegis source-NAT gateway) trusted for forwarded
client addresses. Existing LAN access remains available. No new firewall opening
is required because the existing `192.168.178.0/24` rule includes Aegis.
Before publishing, set a strong permanent Web UI password. A temporary startup
password is not suitable for a public endpoint. Do not bypass authentication for
the reverse proxy or disable CSRF/Host validation.
Namecheap:
- Type: A Record; Host: `downloads`; Value: `179.237.102.172` (Prometheus).
- Do not point this record to Atlas' private LAN address.
NPM on Prometheus:
- Domain Names: `downloads.fscotto.co`
- Scheme: `http`
- Forward Hostname/IP: `192.168.178.55`
- Forward Port: `8090`
- SSL: request/select a certificate for the domain and enable Force SSL.
- No custom Advanced configuration is needed for the currently deployed NPM:
its standard include sets `Host $host`, `X-Forwarded-Proto`, and
`X-Forwarded-For`. Host has no explicit external port, avoiding the Web UI's
internal-port validation. Do not replace it with `Host $http_host` when the
latter includes `:443`.
Reference: <https://github.com/qbittorrent/qBittorrent/wiki/NGINX-Reverse-Proxy-for-Web-UI>.
Public DNS, TLS and end-to-end login remain unverified until the manual setup is
complete. Preparing the Web proxy does not change torrent peer connectivity.
### Reverse-proxy preparation verified on 2026-10-10
Atlas accepts `downloads.fscotto.co` with HTTPS forwarded headers from the NPM
container on Prometheus through Aegis (HTTP 200). Unauthenticated API access is
still denied (403), and an unrelated Host is rejected (401). No DNS record,
NPM Proxy Host, certificate, router forwarding or WireGuard configuration was
changed. The existing LAN firewall rule already permits Aegis. A permanent
Web UI password still needs to be configured before public exposure.