fix(nginx-minio): fix nginx config to enable minio. Fix S3 storage Client

This commit is contained in:
Thomas Rogers 2025-08-30 17:19:57 +02:00
parent e960cb1b1f
commit b5ef86d216
2 changed files with 25 additions and 1 deletions

View file

@ -94,6 +94,7 @@ export class S3StorageClient implements StorageClient {
private urlOverride: string | undefined
private localUrl: string | undefined
private extension: string | undefined
constructor(localUrl: string | undefined, urlOverride: string | undefined) {
this.localUrl = localUrl
@ -103,10 +104,14 @@ export class S3StorageClient implements StorageClient {
endpoint: urlOverride,
})
const signingUrlObj = new URL(localUrl ?? '')
const [signingUrl, extension] = localUrl?.replace(/http[s]?:\/\//g, '')?.split('/') ?? ''.split('/')
this.signingS3Client = new S3Client({
forcePathStyle: true,
endpoint: localUrl,
tls: signingUrlObj.protocol !== 'http:',
endpoint: localUrl?.replace(`/${extension}`, ''),
})
this.extension = extension
}
private createS3UploadStream = (
@ -236,6 +241,14 @@ export class S3StorageClient implements StorageClient {
expiresIn: 900,
})
if (this.extension && this.extension.length > 0) {
const urlObj = new URL(url)
return url.replace(
`${urlObj.protocol}//${urlObj.host}/`,
`${urlObj.protocol}//${urlObj.host}/${this.extension}/`
)
}
return url
}

View file

@ -58,6 +58,17 @@ http {
# Minio
location /bucket {
rewrite ^/bucket/(.*)$ /$1 break;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 300;
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
proxy_http_version 1.1;
proxy_set_header Connection "";
chunked_transfer_encoding off;
proxy_pass http://omnivore_bucket;
}