Question:
I am using aws s3 for static and media files for my django app. Gunicorn and Nginx are being used for application and proxy server.
Nginx setup:
1 2 3 4 5 6 7 8 9 10 |
server { listen 80; server_name sitename.com; location / { include proxy_params; proxy_pass http://unix:/home/SiteNameDjango/myproject/myproject.sock; } } |
Since I am using aws s3 for my static and media files, how should I configure Nginx for my static location? Or there’s no need to configure for the static and media files?
If it helps, here is the Django project settings for aws s3:
1 2 3 4 5 6 7 8 9 10 |
STATICFILES_LOCATION = 'static' MEDIAFILES_LOCATION = 'media' STATICFILES_STORAGE = 'myproject.custom_storages.StaticStorage' DEFAULT_FILE_STORAGE = 'myproject.custom_storages.MediaStorage' AWS_STORAGE_BUCKET_NAME = "django-bucket" AWS_S3_CUSTOM_DOMAIN = AWS_STORAGE_BUCKET_NAME + ".s3.amazonaws.com" STATIC_URL = "https://" + AWS_STORAGE_BUCKET_NAME + ".s3.amazonaws.com/" MEDIA_URL = STATIC_URL + "media/" ADMIN_MEDIA_PREFIX = STATIC_URL + "admin/" |
Eg url:
1 2 |
https://django-bucket.s3.amazonaws.com/media/user_image/1497598249_49.jpeg |
Answer:
In case of S3, nginx is not responsible for serving static and media files and you no need to configure anything.