I have a minio server as my object storage which django uses as its Static file storage (using django-minio-storage
). I have set up an Nginx server to proxy minio. When I run the collectstatic
command, it gets stuck in the first file and does not put the files to minio.
Here is my config:
settings.py
DEFAULT_FILE_STORAGE = "minio_storage.storage.MinioMediaStorage" STATICFILES_STORAGE = "minio_storage.storage.MinioStaticStorage" MINIO_STORAGE_ENDPOINT = config("MINIO_STORAGE_ENDPOINT", "") MINIO_STORAGE_ACCESS_KEY = config("MINIO_STORAGE_ACCESS_KEY", "") MINIO_STORAGE_SECRET_KEY = config("MINIO_STORAGE_SECRET_KEY", "") MINIO_STORAGE_MEDIA_BUCKET_NAME = config("MINIO_STORAGE_MEDIA_BUCKET_NAME", "") MINIO_STORAGE_STATIC_BUCKET_NAME = config("MINIO_STORAGE_STATIC_BUCKET_NAME", "") MINIO_STORAGE_USE_HTTPS = True MINIO_STORAGE_AUTO_CREATE_MEDIA_BUCKET = True MINIO_STORAGE_AUTO_CREATE_STATIC_BUCKET = True MINIO_STORAGE_MEDIA_OBJECT_METADATA = {"Cache-Control": "max-age=3600"}
nginx.conf
user www-data;worker_processes auto;pid /run/nginx.pid;include /etc/nginx/modules-enabled/*.conf;events { worker_connections 500;}http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers on; error_log /dev/stdout; gzip on; server { listen 80; server_name _; ignore_invalid_headers off; client_max_body_size 0; proxy_buffering off; proxy_request_buffering off; location / { 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_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; real_ip_header X-Real-IP; proxy_connect_timeout 300; proxy_http_version 1.1; proxy_set_header Connection ""; chunked_transfer_encoding off; add_header Access-Control-Allow-Origin "*"; proxy_pass http://minio.svc:9000; }}}
collectstatic -v3
result:
Deleting 'admin/js/actions.js'
the collectstatic
command gets stuck here and does not proceed to other files.
My temporary solution was to separate the configs for putting objects and retrieving them. For putting, I use the internal address of minio and it works fine. But this solution is a bit messy and complicates future developments. I would rather find and fix the problem with the current config than investing time on separating the config for all put-object operations.