Django 存储 s3 媒体网址为 https ://instead of http://

标签 django amazon-s3 django-storage

当使用 django-storage s3 提供媒体服务时,正在生成的媒体 URL 是这样的:

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

导致图片因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.

我需要将图像作为 HTTP 而不是 HTTPS

我的设置是:
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
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 文档后,它看起来似乎没有被记录下来,但是这个博客更多地讨论了它。
http://www.eliotk.net/05/30/force-http-with-django-storages-and-s3boto/

关于Django 存储 s3 媒体网址为 https ://instead of http://,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15372041/

相关文章:

java - 使用 AWS TransferManager 时出现 RejectedExecutionException

python - 无法在两个 boto.cfg 文件之间切换

python - Django 1.10 Form 不将数据存储到数据库

python - 如何将附加参数传递给自定义 python 排序函数

hadoop - 无法将Spark作业输出直接写入s3存储桶

django - 对静态文件使用s3,boto,django-storage时,对等方重置连接

django - S3Boto存储和单元测试

python - Django:使用 django-storage 从 S3 创建 zipfile

python - 有或没有 venv 的 Docker?

python - 同模型的django相关key