1

How can I get Django to generate the static URL's using static.mywebsite.com, instead of static.mywebsite.com.s3.amazonaws.com?

The S3 bucket used for static files works when I am using a bucket name with no periods. But with a bucket using periods, it gives Failed to load resource: net::ERR_INSECURE_RESPONSE

The reason I am trying to use a bucket with periods is because this guide and two StackOverflow posts say that this is required to get an address of static.mywebsite.com, instead of mywebsite-static.s3.amazaonaws.com:

http://carltonbale.com/how-to-alias-a-domain-name-or-sub-domain-to-amazon-s3/

how appoint a subdomain for a s3 bucket?

Amazon S3: Static Web Sites: Custom Domain or Subdomain

And it seems to work; when I browse to static.mywebsite.com, I get an XML from S3 saying AccessDenied. In the last link above, a user comments to ask if this will work with HTTPS. It initially appears that it does not.

Upon inspection, the URL's of the static files generated by Django still use the static.mywebsite.com.s3.amazonaws.com address. If I understand correctly, this is a HTTPS certificate issue due to the periods creating additional layers of subdomains.

So, I changed the settings to use:

STATIC_URL = 'https://%s.mywebsite.%s/' % ('static', 'com')

But that resulted in it generating static.s3.amazonaws.com.

How can I get Django to generate the URL's using static.mywebsite.com?

Community
  • 1
  • 1
davidtgq
  • 3,780
  • 10
  • 43
  • 80

0 Answers0