I did setup my Django project, DNS and bucket on Amazon S3 but python manage.py collectstatic
and therefore also files uploaded manually won't works.
AWS S3 Settings:
Bucket name: files.domain.com
Bucket policy:
{
"Id": "Policy1483363850641",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1483363848944",
"Action": "s3:*",
"Effect": "Allow",
"Resource": "arn:aws:s3:::files.domain.com/*",
"Principal": "*"
}
]
}
DNS Settings:
files.domain.com -> CNAME -> files.domain.com.s3.amazonaws.com
Django Settings:
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_ACCESS_KEY_ID = 'XXXXXXXXXXXXXXXXXXXX'
AWS_SECRET_ACCESS_KEY = 'XxXxXXxXXXXXxxxXxxXXXxXxxXXXXXXXXxxxXxxx'
AWS_STORAGE_BUCKET_NAME = 'files.domain.com'
AWS_AUTO_CREATE_BUCKET = False
AWS_QUERYSTRING_AUTH = False
AWS_S3_SECURE_URLS = False
AWS_EXPIRY = 60 * 60 * 24 * 7
AWS_HEADERS = {
'Cache-Control': six.b('max-age=%d, s-maxage=%d, must-revalidate' % (
AWS_EXPIRY, AWS_EXPIRY))
}
MEDIA_URL = 'http://%s/' % AWS_STORAGE_BUCKET_NAME
STATICFILES_STORAGE = DEFAULT_FILE_STORAGE
STATIC_URL = MEDIA_URL