mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 18:29:27 +02:00
Add use proxy for s3 (#4973)
* Fix object storage to be accessible via proxy * fix lint * Use hpagent * Fix lint * Fix PR Co-authored-by: noellabo <noel.yoshiba@gmail.com>
This commit is contained in:
parent
644014cc55
commit
ca3d5912e1
6 changed files with 105 additions and 2 deletions
|
@ -1,8 +1,22 @@
|
|||
import { S3Client } from '@aws-sdk/client-s3'
|
||||
import { NodeHttpHandler } from '@aws-sdk/node-http-handler'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
import { isProxyEnabled } from '@server/helpers/proxy'
|
||||
import { getAgent } from '@server/helpers/requests'
|
||||
import { CONFIG } from '@server/initializers/config'
|
||||
import { lTags } from './logger'
|
||||
|
||||
function getProxyRequestHandler () {
|
||||
if (!isProxyEnabled()) return null
|
||||
|
||||
const { agent } = getAgent()
|
||||
|
||||
return new NodeHttpHandler({
|
||||
httpAgent: agent.http,
|
||||
httpsAgent: agent.https
|
||||
})
|
||||
}
|
||||
|
||||
let endpointParsed: URL
|
||||
function getEndpointParsed () {
|
||||
if (endpointParsed) return endpointParsed
|
||||
|
@ -26,7 +40,8 @@ function getClient () {
|
|||
accessKeyId: OBJECT_STORAGE.CREDENTIALS.ACCESS_KEY_ID,
|
||||
secretAccessKey: OBJECT_STORAGE.CREDENTIALS.SECRET_ACCESS_KEY
|
||||
}
|
||||
: undefined
|
||||
: undefined,
|
||||
requestHandler: getProxyRequestHandler()
|
||||
})
|
||||
|
||||
logger.info('Initialized S3 client %s with region %s.', getEndpoint(), OBJECT_STORAGE.REGION, lTags())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue