]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
404 on unknown thumbnail
authorChocobozzz <me@florianbigard.com>
Tue, 24 Jul 2018 16:02:23 +0000 (18:02 +0200)
committerChocobozzz <me@florianbigard.com>
Tue, 24 Jul 2018 16:03:40 +0000 (18:03 +0200)
server/controllers/static.ts
support/nginx/peertube

index f10427f3e2048722ac2029a07f4b55cf9a2b0332..3ccf624a76832c643dd37293db75351afa951631 100644 (file)
@@ -48,13 +48,13 @@ staticRouter.use(
 const thumbnailsPhysicalPath = CONFIG.STORAGE.THUMBNAILS_DIR
 staticRouter.use(
   STATIC_PATHS.THUMBNAILS,
-  express.static(thumbnailsPhysicalPath, { maxAge: STATIC_MAX_AGE })
+  express.static(thumbnailsPhysicalPath, { maxAge: STATIC_MAX_AGE, fallthrough: false }) // 404 if the file does not exist
 )
 
 const avatarsPhysicalPath = CONFIG.STORAGE.AVATARS_DIR
 staticRouter.use(
   STATIC_PATHS.AVATARS,
-  express.static(avatarsPhysicalPath, { maxAge: STATIC_MAX_AGE })
+  express.static(avatarsPhysicalPath, { maxAge: STATIC_MAX_AGE, fallthrough: false }) // 404 if the file does not exist
 )
 
 // We don't have video previews, fetch them from the origin instance
index 201d95ea22dd6f9f06b1221c8d700b4efc9da66d..01506c7aa54e5bbd79ada58cdc37100b9094201d 100644 (file)
@@ -53,7 +53,7 @@ server {
     alias /var/www/peertube/peertube-latest/client/dist/$1;
   }
 
-  location ~ ^/static/(thumbnails|avatars)/(.*)$ {
+  location ~ ^/static/(thumbnails|avatars)/ {
     if ($request_method = 'OPTIONS') {
       add_header 'Access-Control-Allow-Origin' '*';
       add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
@@ -64,16 +64,17 @@ server {
       return 204;
     }
 
-    if ($request_method = 'GET') {
-      add_header 'Access-Control-Allow-Origin' '*';
-      add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
-      add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
-    }
+    add_header 'Access-Control-Allow-Origin' '*';
+    add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
+    add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
 
     # Cache 2 hours
     add_header Cache-Control "public, max-age=7200";
 
-    alias /var/www/peertube/storage/$1/$2;
+    root /var/www/peertube/storage;
+
+    rewrite ^/static/(thumbnails|avatars)/(.*)$ /$1/$2 break;
+    try_files $uri /;
   }
 
   location / {