aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/controllers/object-storage-proxy.ts3
-rw-r--r--server/controllers/static.ts4
-rw-r--r--server/initializers/constants.ts13
-rw-r--r--server/lib/object-storage/urls.ts2
-rw-r--r--server/models/video/video-file.ts4
-rw-r--r--server/tests/api/object-storage/video-static-file-privacy.ts4
-rw-r--r--server/tests/api/redundancy/redundancy.ts4
-rw-r--r--server/tests/api/videos/video-static-file-privacy.ts2
-rw-r--r--server/tests/shared/videos.ts5
-rw-r--r--support/doc/api/openapi.yaml6
-rw-r--r--support/nginx/peertube12
11 files changed, 31 insertions, 28 deletions
diff --git a/server/controllers/object-storage-proxy.ts b/server/controllers/object-storage-proxy.ts
index 0edde64fe..d0c59bf93 100644
--- a/server/controllers/object-storage-proxy.ts
+++ b/server/controllers/object-storage-proxy.ts
@@ -15,7 +15,8 @@ const objectStorageProxyRouter = express.Router()
15 15
16objectStorageProxyRouter.use(cors()) 16objectStorageProxyRouter.use(cors())
17 17
18objectStorageProxyRouter.get(OBJECT_STORAGE_PROXY_PATHS.PRIVATE_WEBSEED + ':filename', 18objectStorageProxyRouter.get(
19 [ OBJECT_STORAGE_PROXY_PATHS.PRIVATE_WEB_VIDEOS + ':filename', OBJECT_STORAGE_PROXY_PATHS.LEGACY_PRIVATE_WEB_VIDEOS + ':filename' ],
19 ensurePrivateObjectStorageProxyIsEnabled, 20 ensurePrivateObjectStorageProxyIsEnabled,
20 optionalAuthenticate, 21 optionalAuthenticate,
21 asyncMiddleware(ensureCanAccessVideoPrivateWebVideoFiles), 22 asyncMiddleware(ensureCanAccessVideoPrivateWebVideoFiles),
diff --git a/server/controllers/static.ts b/server/controllers/static.ts
index 5ce739bfc..97caa8292 100644
--- a/server/controllers/static.ts
+++ b/server/controllers/static.ts
@@ -29,13 +29,13 @@ const privateWebVideoStaticMiddlewares = CONFIG.STATIC_FILES.PRIVATE_FILES_REQUI
29 : [] 29 : []
30 30
31staticRouter.use( 31staticRouter.use(
32 STATIC_PATHS.PRIVATE_WEBSEED, 32 [ STATIC_PATHS.PRIVATE_WEB_VIDEOS, STATIC_PATHS.LEGACY_PRIVATE_WEB_VIDEOS ],
33 ...privateWebVideoStaticMiddlewares, 33 ...privateWebVideoStaticMiddlewares,
34 express.static(DIRECTORIES.VIDEOS.PRIVATE, { fallthrough: false }), 34 express.static(DIRECTORIES.VIDEOS.PRIVATE, { fallthrough: false }),
35 handleStaticError 35 handleStaticError
36) 36)
37staticRouter.use( 37staticRouter.use(
38 STATIC_PATHS.WEBSEED, 38 [ STATIC_PATHS.WEB_VIDEOS, STATIC_PATHS.LEGACY_WEB_VIDEOS ],
39 express.static(DIRECTORIES.VIDEOS.PUBLIC, { fallthrough: false }), 39 express.static(DIRECTORIES.VIDEOS.PUBLIC, { fallthrough: false }),
40 handleStaticError 40 handleStaticError
41) 41)
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 5116c6396..03ae94d35 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -750,8 +750,13 @@ const STATIC_PATHS = {
750 // TODO: deprecated in v6, to remove 750 // TODO: deprecated in v6, to remove
751 THUMBNAILS: '/static/thumbnails/', 751 THUMBNAILS: '/static/thumbnails/',
752 752
753 WEBSEED: '/static/webseed/', 753 // Need to keep this legacy path for previously generated torrents
754 PRIVATE_WEBSEED: '/static/webseed/private/', 754 LEGACY_WEB_VIDEOS: '/static/webseed/',
755 WEB_VIDEOS: '/static/web-videos/',
756
757 // Need to keep this legacy path for previously generated torrents
758 LEGACY_PRIVATE_WEB_VIDEOS: '/static/webseed/private/',
759 PRIVATE_WEB_VIDEOS: '/static/web-videos/private/',
755 760
756 REDUNDANCY: '/static/redundancy/', 761 REDUNDANCY: '/static/redundancy/',
757 762
@@ -775,7 +780,9 @@ const LAZY_STATIC_PATHS = {
775 STORYBOARDS: '/lazy-static/storyboards/' 780 STORYBOARDS: '/lazy-static/storyboards/'
776} 781}
777const OBJECT_STORAGE_PROXY_PATHS = { 782const OBJECT_STORAGE_PROXY_PATHS = {
778 PRIVATE_WEBSEED: '/object-storage-proxy/webseed/private/', 783 // Need to keep this legacy path for previously generated torrents
784 LEGACY_PRIVATE_WEB_VIDEOS: '/object-storage-proxy/webseed/private/',
785 PRIVATE_WEB_VIDEOS: '/object-storage-proxy/web-videos/private/',
779 786
780 STREAMING_PLAYLISTS: { 787 STREAMING_PLAYLISTS: {
781 PRIVATE_HLS: '/object-storage-proxy/streaming-playlists/hls/private/' 788 PRIVATE_HLS: '/object-storage-proxy/streaming-playlists/hls/private/'
diff --git a/server/lib/object-storage/urls.ts b/server/lib/object-storage/urls.ts
index d25f84026..40619cd5a 100644
--- a/server/lib/object-storage/urls.ts
+++ b/server/lib/object-storage/urls.ts
@@ -30,7 +30,7 @@ function getHLSPrivateFileUrl (video: MVideoUUID, filename: string) {
30} 30}
31 31
32function getWebVideoPrivateFileUrl (filename: string) { 32function getWebVideoPrivateFileUrl (filename: string) {
33 return WEBSERVER.URL + OBJECT_STORAGE_PROXY_PATHS.PRIVATE_WEBSEED + filename 33 return WEBSERVER.URL + OBJECT_STORAGE_PROXY_PATHS.PRIVATE_WEB_VIDEOS + filename
34} 34}
35 35
36// --------------------------------------------------------------------------- 36// ---------------------------------------------------------------------------
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts
index 5e476f3c7..ee34ad2ff 100644
--- a/server/models/video/video-file.ts
+++ b/server/models/video/video-file.ts
@@ -558,10 +558,10 @@ export class VideoFileModel extends Model<Partial<AttributesOnly<VideoFileModel>
558 558
559 private getWebVideoFileStaticPath (video: MVideo) { 559 private getWebVideoFileStaticPath (video: MVideo) {
560 if (isVideoInPrivateDirectory(video.privacy)) { 560 if (isVideoInPrivateDirectory(video.privacy)) {
561 return join(STATIC_PATHS.PRIVATE_WEBSEED, this.filename) 561 return join(STATIC_PATHS.PRIVATE_WEB_VIDEOS, this.filename)
562 } 562 }
563 563
564 return join(STATIC_PATHS.WEBSEED, this.filename) 564 return join(STATIC_PATHS.WEB_VIDEOS, this.filename)
565 } 565 }
566 566
567 private getHLSFileStaticPath (video: MVideo) { 567 private getHLSFileStaticPath (video: MVideo) {
diff --git a/server/tests/api/object-storage/video-static-file-privacy.ts b/server/tests/api/object-storage/video-static-file-privacy.ts
index 18d30a2f5..64ab542a5 100644
--- a/server/tests/api/object-storage/video-static-file-privacy.ts
+++ b/server/tests/api/object-storage/video-static-file-privacy.ts
@@ -39,7 +39,7 @@ describe('Object storage for video static file privacy', function () {
39 const video = await server.videos.getWithToken({ id: uuid }) 39 const video = await server.videos.getWithToken({ id: uuid })
40 40
41 for (const file of video.files) { 41 for (const file of video.files) {
42 expectStartWith(file.fileUrl, server.url + '/object-storage-proxy/webseed/private/') 42 expectStartWith(file.fileUrl, server.url + '/object-storage-proxy/web-videos/private/')
43 43
44 await makeRawRequest({ url: file.fileUrl, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 }) 44 await makeRawRequest({ url: file.fileUrl, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 })
45 } 45 }
@@ -538,7 +538,7 @@ describe('Object storage for video static file privacy', function () {
538 const hlsFilename = extractFilenameFromUrl(getHLS(privateVideo).files[0].fileUrl) 538 const hlsFilename = extractFilenameFromUrl(getHLS(privateVideo).files[0].fileUrl)
539 539
540 await makeRawRequest({ 540 await makeRawRequest({
541 url: server.url + '/object-storage-proxy/webseed/private/' + webVideoFilename, 541 url: server.url + '/object-storage-proxy/web-videos/private/' + webVideoFilename,
542 token: server.accessToken, 542 token: server.accessToken,
543 expectedStatus: HttpStatusCode.BAD_REQUEST_400 543 expectedStatus: HttpStatusCode.BAD_REQUEST_400
544 }) 544 })
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts
index 85da6acf5..0c5c27225 100644
--- a/server/tests/api/redundancy/redundancy.ts
+++ b/server/tests/api/redundancy/redundancy.ts
@@ -125,7 +125,7 @@ async function check1WebSeed (videoUUID?: string) {
125 if (!videoUUID) videoUUID = video1Server2.uuid 125 if (!videoUUID) videoUUID = video1Server2.uuid
126 126
127 const webseeds = [ 127 const webseeds = [
128 `${servers[1].url}/static/webseed/` 128 `${servers[1].url}/static/web-videos/`
129 ] 129 ]
130 130
131 for (const server of servers) { 131 for (const server of servers) {
@@ -145,7 +145,7 @@ async function check2Webseeds (videoUUID?: string) {
145 145
146 const webseeds = [ 146 const webseeds = [
147 `${servers[0].url}/static/redundancy/`, 147 `${servers[0].url}/static/redundancy/`,
148 `${servers[1].url}/static/webseed/` 148 `${servers[1].url}/static/web-videos/`
149 ] 149 ]
150 150
151 for (const server of servers) { 151 for (const server of servers) {
diff --git a/server/tests/api/videos/video-static-file-privacy.ts b/server/tests/api/videos/video-static-file-privacy.ts
index ec4c697db..0a9864134 100644
--- a/server/tests/api/videos/video-static-file-privacy.ts
+++ b/server/tests/api/videos/video-static-file-privacy.ts
@@ -41,7 +41,7 @@ describe('Test video static file privacy', function () {
41 41
42 for (const file of video.files) { 42 for (const file of video.files) {
43 expect(file.fileDownloadUrl).to.not.include('/private/') 43 expect(file.fileDownloadUrl).to.not.include('/private/')
44 expectStartWith(file.fileUrl, server.url + '/static/webseed/private/') 44 expectStartWith(file.fileUrl, server.url + '/static/web-videos/private/')
45 45
46 const torrent = await parseTorrentVideo(server, file) 46 const torrent = await parseTorrentVideo(server, file)
47 expect(torrent.urlList).to.have.lengthOf(0) 47 expect(torrent.urlList).to.have.lengthOf(0)
diff --git a/server/tests/shared/videos.ts b/server/tests/shared/videos.ts
index b7f7a1613..e09bd60b5 100644
--- a/server/tests/shared/videos.ts
+++ b/server/tests/shared/videos.ts
@@ -51,11 +51,12 @@ async function completeWebVideoFilesCheck (options: {
51 expect(file.torrentUrl).to.match(new RegExp(`${server.url}/lazy-static/torrents/${nameReg}.torrent`)) 51 expect(file.torrentUrl).to.match(new RegExp(`${server.url}/lazy-static/torrents/${nameReg}.torrent`))
52 52
53 if (objectStorageBaseUrl && requiresAuth) { 53 if (objectStorageBaseUrl && requiresAuth) {
54 expect(file.fileUrl).to.match(new RegExp(`${originServer.url}/object-storage-proxy/webseed/${privatePath}${nameReg}${extension}`)) 54 const regexp = new RegExp(`${originServer.url}/object-storage-proxy/web-videos/${privatePath}${nameReg}${extension}`)
55 expect(file.fileUrl).to.match(regexp)
55 } else if (objectStorageBaseUrl) { 56 } else if (objectStorageBaseUrl) {
56 expectStartWith(file.fileUrl, objectStorageBaseUrl) 57 expectStartWith(file.fileUrl, objectStorageBaseUrl)
57 } else { 58 } else {
58 expect(file.fileUrl).to.match(new RegExp(`${originServer.url}/static/webseed/${privatePath}${nameReg}${extension}`)) 59 expect(file.fileUrl).to.match(new RegExp(`${originServer.url}/static/web-videos/${privatePath}${nameReg}${extension}`))
59 } 60 }
60 61
61 expect(file.fileDownloadUrl).to.match(new RegExp(`${originServer.url}/download/videos/${nameReg}${extension}`)) 62 expect(file.fileDownloadUrl).to.match(new RegExp(`${originServer.url}/download/videos/${nameReg}${extension}`))
diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yaml
index b2303bdd1..2dfad9987 100644
--- a/support/doc/api/openapi.yaml
+++ b/support/doc/api/openapi.yaml
@@ -366,7 +366,7 @@ x-tagGroups:
366 - Runners 366 - Runners
367 367
368paths: 368paths:
369 '/static/webseed/{filename}': 369 '/static/web-videos/{filename}':
370 get: 370 get:
371 tags: 371 tags:
372 - Static Video Files 372 - Static Video Files
@@ -378,11 +378,11 @@ paths:
378 description: successful operation 378 description: successful operation
379 '404': 379 '404':
380 description: not found 380 description: not found
381 '/static/webseed/private/{filename}': 381 '/static/web-videos/private/{filename}':
382 get: 382 get:
383 tags: 383 tags:
384 - Static Video Files 384 - Static Video Files
385 summary: Get private Web Video video file 385 summary: Get private Web Video file
386 parameters: 386 parameters:
387 - $ref: '#/components/parameters/staticFilename' 387 - $ref: '#/components/parameters/staticFilename'
388 - $ref: '#/components/parameters/videoFileToken' 388 - $ref: '#/components/parameters/videoFileToken'
diff --git a/support/nginx/peertube b/support/nginx/peertube
index f5b9d131a..822f6f9ac 100644
--- a/support/nginx/peertube
+++ b/support/nginx/peertube
@@ -199,7 +199,7 @@ server {
199 alias /var/www/peertube/peertube-latest/client/dist/$1; 199 alias /var/www/peertube/peertube-latest/client/dist/$1;
200 } 200 }
201 201
202 location ~ ^(/static/(webseed|streaming-playlists)/private/)|^/download { 202 location ~ ^(/static/(webseed|web-videos|streaming-playlists)/private/)|^/download {
203 # We can't rate limit a try_files directive, so we need to duplicate @api 203 # We can't rate limit a try_files directive, so we need to duplicate @api
204 204
205 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 205 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -212,16 +212,10 @@ server {
212 } 212 }
213 213
214 # Bypass PeerTube for performance reasons. Optional. 214 # Bypass PeerTube for performance reasons. Optional.
215 location ~ ^/static/(webseed|redundancy|streaming-playlists)/ { 215 location ~ ^/static/(webseed|web-videos|redundancy|streaming-playlists)/ {
216 limit_rate_after 5M; 216 limit_rate_after 5M;
217 217
218 # Clients usually have 4 simultaneous webseed connections, so the real limit is 3MB/s per client 218 set $peertube_limit_rate 5M;
219 set $peertube_limit_rate 800k;
220
221 # Increase rate limit in HLS mode, because we don't have multiple simultaneous connections
222 if ($request_uri ~ -fragmented.mp4$) {
223 set $peertube_limit_rate 5M;
224 }
225 219
226 # Use this line with nginx >= 1.17.0 220 # Use this line with nginx >= 1.17.0
227 limit_rate $peertube_limit_rate; 221 limit_rate $peertube_limit_rate;