chore: Add env for handling uploads SSL Termination (#6722)

This commit is contained in:
Akshat Jain
2025-03-10 15:45:11 +05:30
committed by GitHub
parent 7df63151b5
commit d1e462bb37
3 changed files with 14 additions and 2 deletions

View File

@@ -38,3 +38,6 @@ USE_MINIO=1
# Nginx Configuration # Nginx Configuration
NGINX_PORT=80 NGINX_PORT=80
# Force HTTPS for handling SSL Termination
MINIO_ENDPOINT_SSL=0

View File

@@ -59,4 +59,7 @@ APP_BASE_URL=
# Hard delete files after days # Hard delete files after days
HARD_DELETE_AFTER_DAYS=60 HARD_DELETE_AFTER_DAYS=60
# Force HTTPS for handling SSL Termination
MINIO_ENDPOINT_SSL=0

View File

@@ -32,6 +32,12 @@ class S3Storage(S3Boto3Storage):
) or os.environ.get("MINIO_ENDPOINT_URL") ) or os.environ.get("MINIO_ENDPOINT_URL")
if os.environ.get("USE_MINIO") == "1": if os.environ.get("USE_MINIO") == "1":
# Determine protocol based on environment variable
if os.environ.get("MINIO_ENDPOINT_SSL") == "1":
endpoint_protocol = "https"
else:
endpoint_protocol = request.scheme if request else "http"
# Create an S3 client for MinIO # Create an S3 client for MinIO
self.s3_client = boto3.client( self.s3_client = boto3.client(
"s3", "s3",
@@ -39,7 +45,7 @@ class S3Storage(S3Boto3Storage):
aws_secret_access_key=self.aws_secret_access_key, aws_secret_access_key=self.aws_secret_access_key,
region_name=self.aws_region, region_name=self.aws_region,
endpoint_url=( endpoint_url=(
f"{request.scheme}://{request.get_host()}" f"{endpoint_protocol}://{request.get_host()}"
if request if request
else self.aws_s3_endpoint_url else self.aws_s3_endpoint_url
), ),