title: Django won't serve static files from Amazon S3 with custom domain
body: <p>I did setup my Django project, DNS and bucket on Amazon S3 but <code>python manage.py collectstatic</code> and therefore also files uploaded manually won't works.</p>
  
  <p><strong>AWS S3 Settings:</strong></p>
  
  <p>Bucket name: files.domain.com</p>
  
  <p>Bucket policy:</p>
  
  <pre><code>{
    "Id": "Policy1483363850641",
    "Version": "2012-10-17",
    "Statement": [
      {
        "Sid": "Stmt1483363848944",
        "Action": "s3:*",
        "Effect": "Allow",
        "Resource": "arn:aws:s3:::files.domain.com/*",
        "Principal": "*"
      }
    ]
  }
  </code></pre>
  
  <p><strong>DNS Settings:</strong></p>
  
  <p>files.domain.com -> CNAME -> files.domain.com.s3.amazonaws.com</p>
  
  <p><strong>Django Settings:</strong></p>
  
  <pre><code>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
  </code></pre>