diff options
author | Chocobozzz <me@florianbigard.com> | 2018-07-24 18:02:23 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-07-24 18:03:40 +0200 |
commit | a8bf1d826e379dec03d25840c7c49c1f30168380 (patch) | |
tree | 5f122d1012f1e3267f218c0e8f155674454ca8d0 | |
parent | a8981e0b24ad41d9124344a780d878b08cef173b (diff) | |
download | PeerTube-a8bf1d826e379dec03d25840c7c49c1f30168380.tar.gz PeerTube-a8bf1d826e379dec03d25840c7c49c1f30168380.tar.zst PeerTube-a8bf1d826e379dec03d25840c7c49c1f30168380.zip |
404 on unknown thumbnail
-rw-r--r-- | server/controllers/static.ts | 4 | ||||
-rw-r--r-- | support/nginx/peertube | 15 |
2 files changed, 10 insertions, 9 deletions
diff --git a/server/controllers/static.ts b/server/controllers/static.ts index f10427f3e..3ccf624a7 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts | |||
@@ -48,13 +48,13 @@ staticRouter.use( | |||
48 | const thumbnailsPhysicalPath = CONFIG.STORAGE.THUMBNAILS_DIR | 48 | const thumbnailsPhysicalPath = CONFIG.STORAGE.THUMBNAILS_DIR |
49 | staticRouter.use( | 49 | staticRouter.use( |
50 | STATIC_PATHS.THUMBNAILS, | 50 | STATIC_PATHS.THUMBNAILS, |
51 | express.static(thumbnailsPhysicalPath, { maxAge: STATIC_MAX_AGE }) | 51 | express.static(thumbnailsPhysicalPath, { maxAge: STATIC_MAX_AGE, fallthrough: false }) // 404 if the file does not exist |
52 | ) | 52 | ) |
53 | 53 | ||
54 | const avatarsPhysicalPath = CONFIG.STORAGE.AVATARS_DIR | 54 | const avatarsPhysicalPath = CONFIG.STORAGE.AVATARS_DIR |
55 | staticRouter.use( | 55 | staticRouter.use( |
56 | STATIC_PATHS.AVATARS, | 56 | STATIC_PATHS.AVATARS, |
57 | express.static(avatarsPhysicalPath, { maxAge: STATIC_MAX_AGE }) | 57 | express.static(avatarsPhysicalPath, { maxAge: STATIC_MAX_AGE, fallthrough: false }) // 404 if the file does not exist |
58 | ) | 58 | ) |
59 | 59 | ||
60 | // We don't have video previews, fetch them from the origin instance | 60 | // We don't have video previews, fetch them from the origin instance |
diff --git a/support/nginx/peertube b/support/nginx/peertube index 201d95ea2..01506c7aa 100644 --- a/support/nginx/peertube +++ b/support/nginx/peertube | |||
@@ -53,7 +53,7 @@ server { | |||
53 | alias /var/www/peertube/peertube-latest/client/dist/$1; | 53 | alias /var/www/peertube/peertube-latest/client/dist/$1; |
54 | } | 54 | } |
55 | 55 | ||
56 | location ~ ^/static/(thumbnails|avatars)/(.*)$ { | 56 | location ~ ^/static/(thumbnails|avatars)/ { |
57 | if ($request_method = 'OPTIONS') { | 57 | if ($request_method = 'OPTIONS') { |
58 | add_header 'Access-Control-Allow-Origin' '*'; | 58 | add_header 'Access-Control-Allow-Origin' '*'; |
59 | add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS'; | 59 | add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS'; |
@@ -64,16 +64,17 @@ server { | |||
64 | return 204; | 64 | return 204; |
65 | } | 65 | } |
66 | 66 | ||
67 | if ($request_method = 'GET') { | 67 | add_header 'Access-Control-Allow-Origin' '*'; |
68 | add_header 'Access-Control-Allow-Origin' '*'; | 68 | add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS'; |
69 | add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS'; | 69 | add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; |
70 | add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; | ||
71 | } | ||
72 | 70 | ||
73 | # Cache 2 hours | 71 | # Cache 2 hours |
74 | add_header Cache-Control "public, max-age=7200"; | 72 | add_header Cache-Control "public, max-age=7200"; |
75 | 73 | ||
76 | alias /var/www/peertube/storage/$1/$2; | 74 | root /var/www/peertube/storage; |
75 | |||
76 | rewrite ^/static/(thumbnails|avatars)/(.*)$ /$1/$2 break; | ||
77 | try_files $uri /; | ||
77 | } | 78 | } |
78 | 79 | ||
79 | location / { | 80 | location / { |