Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • funkwhale funkwhale
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 407
    • Issues 407
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 16
    • Merge requests 16
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Terraform modules
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • funkwhalefunkwhale
  • funkwhalefunkwhale
  • Merge requests
  • !959

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

  • Review changes

  • Download
  • Patches
  • Plain diff
Merged Agate requested to merge media-root into develop Nov 26, 2019
  • Overview 0
  • Commits 1
  • Pipelines 3
  • Changes 5

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 Nov 27, 2019 by Agate
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: media-root