title: 403 Forbidden on Django Storages css/js files with Amazon S3 on an EC2 Instance
body: <p>I have been googling for two days and none of the answers are resolving the issue.</p>
  
  <p><strong>The setup</strong></p>
  
  <pre><code>AWS_S3_ACCESS_KEY_ID = 'xxxxxxx'
  AWS_S3_SECRET_ACCESS_KEY = 'xxxxxxxxx'
  AWS_STORAGE_BUCKET_NAME = 'my-bucket.mycompany.com'
  COMPRESS_URL = 'http://{}.s3.amazon.com/'.format(AWS_STORAGE_BUCKET_NAME)
  STATIC_URL = COMPRESS_URL
  AWS_S3_FILE_OVERWRITE = True
  AWS_S3_SECURE_URLS = True
  AWS_QUERYSTRING_AUTH = False
  AWS_S3_CUSTOM_DOMAIN = '{}.s3-external-3.amazonaws.com'.format(AWS_STORAGE_BUCKET_NAME)
  </code></pre>
  
  <p><strong>The googling</strong></p>
  
  <p><a href="http://abourazanis.com/2014/Amazon-S3-403-forbidden-Error/" rel="nofollow noreferrer">Incorrect date/time on server</a>  :  This an EC-2 instance, but even though I installed <code>yum install ntp ntpdate ntp-doc</code> -- NO LUCK</p>
  
  <p><a href="https://github.com/django-compressor/django-compressor/issues/229" rel="nofollow noreferrer">AWS_QUERY_STRING_AUTH</a> : Multiple sources online say to do this, but didn't resolve my issue</p>
  
  <p><a href="https://stackoverflow.com/questions/9651052/why-are-my-compressed-files-on-s3-returning-a-403-forbidden-error">AWS_QUERY_STRING_AUTH</a>: Yet again</p>
  
  <p><a href="https://stackoverflow.com/questions/16623901/error-when-trying-to-compress-static-files-when-using-django-storages-and-django">AWS_S3_CUSTOM_DOMAIN</a> No luck here either</p>
  
  <p><strong>The experiment</strong></p>
  
  <pre><code># ON THE EC2 BOX
  ./manage.py shell
  from boto.s3.connection import S3Connection
  from django.conf import settings
  conn = S3Connection(settings.AWS_S3_ACCESS_KEY_ID, settings.AWS_S3_SECRET_ACCESS_KEY)
  b = conn.get_bucket('my-bucket.mycompany.com')
  key = b.get_key('500.html')
  print key.get_contents_as_string()  # WORKS FINE
  </code></pre>
  
  <p>However when I run <code>./manage.py compress</code> I get </p>
  
  <pre><code>CommandError: An error occured during renderinghome_4770.html:
  'https://mybucket.mycompany.com.s3-external-3.amazonaws.com/css/smoothness/jquery-ui-1.10.1.custom.css'
   isn't accessible via COMPRESS_URL    ('http://mybucket.mycompany.com.s3.amazon.com/') and can't be compressed
  </code></pre>
  
  <p>Before you ask, yes the file is available on that bucket.  I also tried the traditional way of django-storages with offline compression, using <code>&lt;project-root&gt;/static</code> as <code>STATIC_ROOT</code>, then uploading the contents of <code>./manage.py collectstatic</code> AND <code>./manage.py compress</code> :, i.e. the resulting css/js and <code>manifest_1.json</code> files to the bucket, but in the browser, I still get <code>403 Forbidden</code> on css/js files</p>
  
  <p>Any ideas on what may be going on??</p>