Skip to content

Make media and static files serving more reliable when reverse proxy...

Agate requested to merge media-root into develop

Make media and static files serving more reliable when reverse proxy X_FORWARDED_* headers are incorrect.

It's one of the most common issue, cf https://governance.funkwhale.audio/d/jtavw8gh/set-up-on-headless-server-with-docker/3 for instance, and it occurs when X-Forwarded-Proto and X-Forwarded-Host headers are set incorrectly, which is really easy to when you have multiple proxies nested together.

The root cause of the issue is that MEDIA_URL is traditionally a relative path, and that Django concatenates this path to the host from the request headers. When those headers are not set correctly at the reverse-proxy level, you typically end up with urls such as http://127.0.0.1/media/ instead of https://yourdomain/media.

This MR bypass this Django behaviour entirely, by setting by default an absolute URL for MEDIA_URL using {FUNKWHALE_URL}/media/.

cc @funkwhale/reviewers-sysadmin @funkwhale/reviewers-python

Fix #947 (closed): and possibly other issues

Edited by Agate

Merge request reports