title: Django Storages failing to upload static files in nginx and docker configuration
body: <p>I am unable to get NGINX (which I think is the culprit) to work with django-storages when a media file is uploaded. It will receive static files from my S3 bucket, but it just refuses to post to it. Whenever an image is uploaded to the site I will get a NGINX 500 Internal Server Error. It works with the default django runserver application and I am unsure what is causing this to fail. This is all run in a docker container. Here is what I have: </p>
  
  <p>Settings, showing how storages is set-up</p>
  
  <pre><code>AWS_STORAGE_BUCKET_NAME = 'sitename-staticfiles'
  AWS_S3_REGION_NAME = 'us-east-1'
  AWS_ACCESS_KEY_ID= 'access_key'
  AWS_SECRET_ACCESS_KEY= 'secret_key'
  
  AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
  AWS_QUERYSTRING_AUTH = False
  STATIC_URL = '/static/'
  
  MEDIA_URL = '/media/'
  AWS_DEFAULT_ACL = None
  STATICFILES_LOCATION = 'static'
  STATICFILES_STORAGE = 'custom_storages.StaticStorage'
  STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static', 'sitename')]
  
  MEDIAFILES_LOCATION = 'media'
  DEFAULT_FILE_STORAGE = 'custom_storages.MediaStorage'
  </code></pre>
  
  <p>custom_storages.py</p>
  
  <pre><code>from django.conf import settings
  from storages.backends.s3boto3 import S3Boto3Storage
  
  class StaticStorage(S3Boto3Storage):
      location = settings.STATICFILES_LOCATION
  
  class MediaStorage(S3Boto3Storage):
      location = settings.MEDIAFILES_LOCATION
  </code></pre>
  
  <p>nginx.conf</p>
  
  <pre><code>user nobody;
  worker_processes auto;
  pid /run/nginx.pid;
  
  events {
          worker_connections 768;
          # multi_accept on;
  }
  
  http {
  
          ##
          # Basic Settings
          ##
  
          sendfile on;
          tcp_nopush on;
          tcp_nodelay on;
          keepalive_timeout 65;
          types_hash_max_size 2048;
          # server_tokens off;
  
          # server_names_hash_bucket_size 64;
          # server_name_in_redirect off;
  
          include /etc/nginx/mime.types;
          default_type application/octet-stream;
  
  
          server {
                listen 80 default_server;
                listen [::]:80 default_server;
                server_name sitename.com localhost;
                 location / {
                          include         uwsgi_params;
                          uwsgi_param     SCRIPT_NAME /;
                          uwsgi_pass          unix:///var/tmp/sitename.sock;
                          proxy_redirect     off;
                          proxy_buffering    off;
                          proxy_set_header   Host              $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-Host  $server_name;
                          proxy_set_header   X-Forwarded-Proto $scheme;
  
                  }
          }
  
          ##
          # SSL Settings
          ##
  
          ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
          ssl_prefer_server_ciphers on;
  
          ##
          # Logging Settings
          ##
  
          access_log /var/log/nginx/access.log;
          error_log /var/log/nginx/error.log;
  
          ##
          # Gzip Settings
          ##
  
          gzip on;
          gzip_disable "msie6";
  
          gzip_vary on;
          gzip_proxied any;
          gzip_comp_level 6;
          gzip_buffers 16 8k;
          gzip_http_version 1.1;
          gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
  
          ##
          # Virtual Host Configs
          ##
  
          #include /etc/nginx/conf.d/*.conf;
          #include /etc/nginx/sites-enabled/*;
  }
  </code></pre>
  
  <p>uwsgi.ini</p>
  
  <pre><code>[uwsgi]
  
  # Django-related settings
  
  # the base directory (full path)
  chdir           = %d
  
  # Django's wsgi file
  module          = sitename.wsgi
  
  # the virtualenv (full path)
  # home            = /
  
  #socket=:8000
  # http = 0.0.0.0:8000
  # process-related settings
  # master
  master          = true
  # maximum number of worker processes
  processes       = 4
  # the socket (use the full path to be safe
  socket          = /var/tmp/sloopsnoop.sock
  # ... with appropriate permissions - may be needed
  chmod-socket    = 666
  # clear environment on exit
  vacuum          = true
  </code></pre>
  
  <p>docker-compose.yaml</p>
  
  <pre><code>version: '3.7'
  
  services:
    web:
      build: ./app
      entrypoint: ./entrypoint-prod.sh
      volumes:
        - ./app/:/usr/src/app/
        - static_volume:/usr/src/app/static/
        - media_volume:/usr/src/app/media/
      ports:
        - 8085:80
      env_file:
        - ./.env.dev
      depends_on:
        - db
    db:
      image: postgres:12-alpine
      volumes:
        - postgres_data:/var/lib/postgresql/data/
      environment:
        - POSTGRES_USER=username
        - POSTGRES_PASSWORD=password
        - POSTGRES_DB=sitename_db_dev
  
  volumes:
    postgres_data:
    static_volume:
    media_volume:
  </code></pre>