问题描述
在与django-storage s3一起提供媒体时,正在生成的媒体网址如下所示:
https: //mybucket.s3.amazonaws.com/myimage.jpg?Signature=5ifoyLqzmtfVNS1ovfzVvN92RH0%3D&Expires=1363124819&AWSAccessKeyId=AKIAJ7ZTU7K4SPYKGOFA
由于https:导致图像不显示
您尝试访问mybucket.s3.amazonaws .com,
,而是你实际上到达了一个将自己标识为* .s3.amazonaws.com的服务器。
这可能是由于服务器配置错误或更严重的原因。您的网络上的攻击者可能会试图让您访问mybucket.s3.amazonaws.com的假冒(可能有害)的版本。
我需要将图像作为HTTP而不是HTTPS >
我的设置是:
DEFAULT_FILE_STORAGE ='storages.backends.s3boto.S3BotoStorage '
/ pre>
AWS_ACCESS_KEY_ID =AKIAJ .... K4SPYKGOFA
AWS_SECRET_ACCESS_KEY =2Y7G98JoCRzAEp .... rPoCjWZuwDaQ
AWS_STORAGE_BUCKET_NAME =mybucket
我尝试将media_url和s3_url设置为普通的http,但没有改变任何东西。
我正在使用django 1.5
解决方案我会尝试将此属性添加到您的设置中:
AWS_S3_SECURE_URLS = False
看起来并不像以前那样简单的扫描django-storages文档,但这个博客更多地谈到了这一点。
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
解决方案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/
这篇关于Django storage s3 media url是https://而不是http://的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!