diff --git a/.config/docker_example.yml b/.config/docker_example.yml index d492bee81d..8b8b14ff6b 100644 --- a/.config/docker_example.yml +++ b/.config/docker_example.yml @@ -187,6 +187,10 @@ proxyBypassHosts: # Media Proxy #mediaProxy: https://example.com/proxy +# Proxy remote files endpoint +# remoteProxy: https://example.com/files/ +# remoteProxy: /files/ + # Proxy remote files (default: true) proxyRemoteFiles: true diff --git a/.config/example.yml b/.config/example.yml index 866d94df1c..b5210e3fde 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -285,6 +285,10 @@ proxyBypassHosts: # * Perform image compression (on a different server resource than the main process) #mediaProxy: https://example.com/proxy +# Proxy remote files endpoint +# remoteProxy: https://example.com/files/ +# remoteProxy: /files/ + # Proxy remote files (default: true) # Proxy remote files by this instance or mediaProxy to prevent remote files from running in remote domains. proxyRemoteFiles: true diff --git a/CHANGELOG_yojo.md b/CHANGELOG_yojo.md new file mode 100644 index 0000000000..3706f167fc --- /dev/null +++ b/CHANGELOG_yojo.md @@ -0,0 +1,31 @@ + +## 0.1.0 (unreleased) + +### Release Date +2024-03-09 + +### General +- メディアプロキシurlと拡大画像urlを分割 + +### Server +- remoteProxyエンドポイント設定を追加 + +### Others +- engawaをマージ +- cherrypickからフォーク diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts index 7ba2e568a2..d93582112b 100644 --- a/packages/backend/src/config.ts +++ b/packages/backend/src/config.ts @@ -102,6 +102,7 @@ type Source = { apFileBaseUrl?: string; mediaProxy?: string; + remoteProxy?: string; proxyRemoteFiles?: boolean; videoThumbnailGenerator?: string; @@ -197,6 +198,7 @@ export type Config = { clientEntry: string; clientManifestExists: boolean; mediaProxy: string; + remoteProxy?: string; externalMediaProxyEnabled: boolean; videoThumbnailGenerator: string | null; redis: RedisOptions & RedisOptionsSource; @@ -246,6 +248,11 @@ export function loadConfig(): Config { config.mediaProxy.endsWith('/') ? config.mediaProxy.substring(0, config.mediaProxy.length - 1) : config.mediaProxy : null; const internalMediaProxy = `${scheme}://${host}/proxy`; + + const remoteProxy = config.remoteProxy ? + config.remoteProxy.endsWith('/') ? config.remoteProxy.substring(0, config.remoteProxy.length - 1) : config.remoteProxy + : null; + const redis = convertRedisOptions(config.redis, host); return { @@ -297,6 +304,7 @@ export function loadConfig(): Config { apFileBaseUrl: config.apFileBaseUrl, mediaProxy: externalMediaProxy ?? internalMediaProxy, externalMediaProxyEnabled: externalMediaProxy !== null && externalMediaProxy !== internalMediaProxy, + remoteProxy, videoThumbnailGenerator: config.videoThumbnailGenerator ? config.videoThumbnailGenerator.endsWith('/') ? config.videoThumbnailGenerator.substring(0, config.videoThumbnailGenerator.length - 1) : config.videoThumbnailGenerator : null, diff --git a/packages/backend/src/core/entities/DriveFileEntityService.ts b/packages/backend/src/core/entities/DriveFileEntityService.ts index 15782b9298..0e1c7f49bc 100644 --- a/packages/backend/src/core/entities/DriveFileEntityService.ts +++ b/packages/backend/src/core/entities/DriveFileEntityService.ts @@ -110,6 +110,18 @@ export class DriveFileEntityService { @bindThis public getPublicUrl(file: MiDriveFile, mode?: 'avatar', ap?: boolean): string { // static = thumbnail + // PublicUrlにはexternalMediaProxyEnabledでもremoteProxyを使う + // https://github.com/yojo-art/cherrypick/issues/84 + if (file.uri != null && file.userHost != null && mode !== 'avatar' && this.config.remoteProxy != null) { + //下のローカルプロキシからコピペで持ってきた + const key = file.webpublicAccessKey; + if (key && !key.match('/')) { // 古いものはここにオブジェクトストレージキーが入ってるので除外 + if (this.config.remoteProxy.startsWith('/')) { + return `${this.config.url}${this.config.remoteProxy}/${key}`; + } + return `${this.config.remoteProxy}/${key}`; + } + } // リモートかつメディアプロキシ if (file.uri != null && file.userHost != null && this.config.externalMediaProxyEnabled) { return this.getProxiedUrl(file.uri, mode);