Atma
Atma

Reputation: 29767

can't access django site after HTTPS setup

I have a django site that is installed on apache on centos/Amazon linux AMI. I installed mod_ssl on apache to be able to use https.

On the django side I added the following security contstants to settings:

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

When I go to https://example.com/admin I get a 404.

Previously when I went to this url (or any other) it redirected without issue.

I added the values above based on the instructions here: https://docs.djangoproject.com/en/1.9/topics/security/#ssl-https

What do I need to configure on django additionally to be able to render urls correctly over https?

Upvotes: 0

Views: 1249

Answers (1)

Atma
Atma

Reputation: 29767

The problem was that I needed to set a virtual host entry in /etc/httpd/conf.d/ssl.conf

After I did this, the site worked no problem.

Upvotes: 1

Related Questions