From 4a1bd56fd97f3c31955c9317aafb446e4aeea8f1 Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Wed, 21 Dec 2022 14:39:56 +0100 Subject: [PATCH] Update nginx proxy of media files --- nummi.nginx | 2 +- nummi/nummi/urls.py | 2 +- nummi/nummi/views.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nummi.nginx b/nummi.nginx index 28147a4..0e8ba04 100644 --- a/nummi.nginx +++ b/nummi.nginx @@ -13,7 +13,7 @@ server { alias /srv/nummi; } - location /media { + location /internal/media { internal; alias /var/lib/nummi; } diff --git a/nummi/nummi/urls.py b/nummi/nummi/urls.py index 21c2231..126b44a 100644 --- a/nummi/nummi/urls.py +++ b/nummi/nummi/urls.py @@ -23,7 +23,7 @@ from django.conf.urls.static import static from . import views urlpatterns = [ - path("media/", views.media, name="media"), + path("media/", views.media, name="media"), ] + i18n_patterns( path("", include("main.urls")), path("plot/", include("plot.urls")), diff --git a/nummi/nummi/views.py b/nummi/nummi/views.py index 1f84722..a79c117 100644 --- a/nummi/nummi/views.py +++ b/nummi/nummi/views.py @@ -2,8 +2,8 @@ from django.http import HttpResponse from django.contrib.auth.decorators import login_required @login_required -def media(request): +def media(request, path): _res = HttpResponse() _res["Content-Type"] = "" - _res["X-Accel-Redirect"] = request.path + _res["X-Accel-Redirect"] = "/internal/media/" + path return _res