Update nginx proxy of media files

This commit is contained in:
Edgar P. Burkhart 2022-12-21 14:39:56 +01:00
parent 55021db557
commit 4a1bd56fd9
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
3 changed files with 4 additions and 4 deletions

View file

@ -13,7 +13,7 @@ server {
alias /srv/nummi;
}
location /media {
location /internal/media {
internal;
alias /var/lib/nummi;
}

View file

@ -23,7 +23,7 @@ from django.conf.urls.static import static
from . import views
urlpatterns = [
path("media/", views.media, name="media"),
path("media/<path>", views.media, name="media"),
] + i18n_patterns(
path("", include("main.urls")),
path("plot/", include("plot.urls")),

View file

@ -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