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:
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:
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:
https://django-bucket.s3.amazonaws.com/media/user_image/1497598249_49.jpeg
You can use both NGINX Open Source and NGINX Plus as the gateway to S3 or a compatible object store. To use NGINX Open Source, start with the official NGINX image from Docker Hub and the Dockerfile we provide on GitHub.
In AWS, Simple Storage Service (S3) is used to store any kind of data blobs on an object storage back end with unlimited capacity.
In case of S3, nginx is not responsible for serving static and media files and you no need to configure anything.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With