I set several settings as django document said, but i got two problem:
SecurityMiddleware
didn't work- once
SECURE_SSL_REDIRECT = True
website will can't be visited
SecurityMiddleware
supposed to set Strict-Transport-Security: max-age=31536000; includeSubDomains
is responde header, but i check by chrome F12 , response header is like that:
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Date: Thu, 13 Jun 2019 02:18:17 GMT
Server: openresty/1.15.8.1
Set-Cookie: uid=e59e2b54f7d64a6799b0f160dc80fae6; expires=Sun, 10 Jun 2029 02:18:17 GMT; HttpOnly; Max-Age=315360000; Path=/
Transfer-Encoding: chunked
X-Frame-Options: SAMEORIGIN
no Strict-Transport-Security in it
i use nginx to redirect , but i still wondering why SECURE_SSL_REDIRECT = True
cause website unavliabe to visit, and if this setting has other affect?
chrome shows ERR_TOO_MANY_REDIRECTS
django settings:
MIDDLEWARE = [
# 'django.middleware.cache.UpdateCacheMiddleware',
'blog.middleware.user_id.UserIDMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ALLOWED_HOSTS = ['www.xxxxxx.club']
#SECURE_SSL_REDIRECT = True
CSRF_COOKIE_SECURE = True
SESSION_COOKIE_SECURE = True
SECURE_HSTS_SECONDS = 31536000
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_HSTS_PRELOAD = True