HTTPS设置后无法访问django网站

时间:2016-05-24 23:12:27

标签: python django apache ssl https

我有一个安装在centos / Amazon linux AMI上的apache上的django站点。我在apache上安装了mod_ssl以便能够使用https。

在django方面,我将以下安全性常量添加到设置中:

SECURE_SSL_REDIRECT = True
SECURE_HSTS_SECONDS = 3600
SESSION_COOKIE_SECURE = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTOCOL', 'https')
CSRF_COOKIE_SECURE = True

当我去https://example.com/admin时,我得到了404。

之前,当我访问此网址(或任何其他网址)时,它会重定向而没有问题。

我根据以下说明添加了上述值:https://docs.djangoproject.com/en/1.9/topics/security/#ssl-https

我还需要在django上配置什么才能通过https正确呈现网址?

1 个答案:

答案 0 :(得分:1)

问题是我需要在/etc/httpd/conf.d/ssl.conf中设置虚拟主机条目

在我这样做之后,网站没有问题。

相关问题