[Dispatcharr] Logo cache URLs generated with wrong scheme (http) and internal port (9191) when behind a reverse proxy #15143
Replies: 3 comments 3 replies
-
|
This is something way out of scope of our scripts. Not all users use a Proxy for starters. Second, we can not change any NPM or other proxy settings with our scritps. I convert this to a discussion if anyone has this issue, but the script will not reflect this changes. |
Beta Was this translation helpful? Give feedback.
-
|
@michelroegl-brunner Just adding to this - Dispatcharr's own Docker nginx config sets the following headers at the server block level And so I think it's fair to expect the LXC to be reachable in the same way as the official docker image - either via IP:PORT or via a reverse proxy. The community script's generated Again, this is not a change to any external proxy configuration, it is purely a fix to the nginx config that the community script itself generates. It makes the LXC install behave similarly to the Docker install that Dispatcharr's own developers have already correctly configured, while remaining fully backwards compatible for users accessing Dispatcharr directly via IP:port without any reverse proxy. |
Beta Was this translation helpful? Give feedback.
-
|
@michelroegl-brunner any thoughts on the above, as I feel perhaps you confused my request for me asking to change NPM or other proxy settings which is not the case. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Script: Dispatcharr
Reported by: @snorkrat
Guidelines
Issue occurs during: Initial Creation / Installation
Environment
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/dispatcharr.sh)"Description
When Dispatcharr is installed via the community script and accessed through a reverse proxy (e.g. Nginx Proxy Manager) via a domain name over HTTPS, the Django backend generates incorrect
cache_urlvalues for channel logos. Instead of using the external scheme and port, URLs are built using the internal values, producing broken URLs like:http://dispatcharr.yourdomain.com:9191/api/channels/logos/1/cache/These URLs are then requested by the browser directly on port 9191, which is not externally accessible, resulting in
ERR_CONNECTION_REFUSEDerrors for every logo and no logos displaying in the web UI and the URLs in the cached EPG XML contain the port.The root cause is in
/etc/nginx/sites-available/dispatcharr.conf. The internal nginx (which listens on 9191 and proxies to uWSGI on 5656) usesinclude proxy_paramsin thelocation /block. This overwrites theX-Forwarded-Protoheader set by the upstream reverse proxy with$scheme(which ishttpon the internal connection), and passes noX-Forwarded-Portat all. Django'sbuild_absolute_uri()therefore seeshttpand port9191when constructing absolute URLs.Additionally, removing
include proxy_paramswithout care causes theHostheader to be set twice (once byproxy_paramsand once explicitly), resulting in Django receiving a duplicated value (yourdomain.com, yourdomain.com) and rejecting all requests with a400 Bad Requesterror.Steps to reproduce
logos/?no_pagination=trueAPI responsecache_urlfor every logo containshttp://and:9191, e.g.:http://dispatcharr.yourdomain.com:9191/api/channels/logos/1/cache/ERR_CONNECTION_REFUSEDerrors in the Console tab for every logo requestError output
n/a
Additional context
Fix - Part 1: LXC internal nginx config
Replace the contents of
/etc/nginx/sites-available/dispatcharr.confon the LXC with the following:Then restart nginx on the LXC:
Fix — Part 2: Reverse Proxy (e.g. Nginx Proxy Manager) config
Ensure your reverse proxy is explicitly sending
X-Forwarded-Portto the LXC. Without this header, the LXC nginx has no way to know the external port and falls back to its internal port (9191).Add
proxy_set_header X-Forwarded-Port $server_port;to all location blocks in the reverse proxy config provided in the Dispatcharr docs. Since NPM listens on 443 for HTTPS,$server_portwill correctly be443:Why this fixes it
The
mapblocks provide fallback behaviour that makes the config work correctly in both directip:portaccess and reverse proxy scenarios:X-Forwarded-Protois present (sent by the reverse proxy) → use it (https); otherwise fall back to$scheme(http) which is correct for direct accessX-Forwarded-Portis present (sent by the reverse proxy) → use it (443); otherwise fall back to$server_port(9191) which is correct for direct accessThis means:
httpsand443→ builds correct URLs likehttps://dispatcharr.yourdomain.com/api/channels/logos/1/cache/httpand9191→ builds correct URLs likehttp://10.0.1.44:9191/api/channels/logos/1/cache/Removing
include proxy_paramseliminates theHostheader duplication issue. Theproxy_paramsfile setsHost $host, and having it set again explicitly in the location block caused nginx to concatenate them intoyourdomain.com, yourdomain.com, which Django rejected with a400 Bad Requesterror.Beta Was this translation helpful? Give feedback.
All reactions