djangoamazon-s3django-storage

Django storage s3 media url is https:// instead of http://


When serving media with django-storage s3, the media url that is being generated is something like this:

https://mybucket.s3.amazonaws.com/myimage.jpg?Signature=5ifoyLqzmtfVNS1ovfzVvN92RH0%3D&Expires=1363124819&AWSAccessKeyId=AKIAJ7ZTU7K4SPYKGOFA

Causing the images to not be displayed because of https:

    You attempted to reach mybucket.s3.amazonaws.com,
 but instead you actually reached a server identifying itself as *.s3.amazonaws.com.
 This may be caused by a misconfiguration on the server or by something more serious. An attacker on your network could be trying to get you to visit a fake (and potentially harmful) version of mybucket.s3.amazonaws.com.

I need the images to be served as HTTP not HTTPS

My settings are:

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_ACCESS_KEY_ID = "AKIAJ....K4SPYKGOFA"
AWS_SECRET_ACCESS_KEY = "2Y7G98JoCRzAEp....rPoCjWZuwDaQ"
AWS_STORAGE_BUCKET_NAME = "mybucket"

I tried set the media_url, and s3_url to normal http, but it didn't change anything.

I'm using django 1.5


Solution

  • I would try adding this property to your settings:

    AWS_S3_SECURE_URLS = False
    

    It doesn't look like it's documented after a brief glance at the django-storages docs, but this blog talks about it a bit more. http://www.eliotk.net/05/30/force-http-with-django-storages-and-s3boto/