我正在尝试为我的Django应用程序设置SSL,使用Heroku进行部署,并且在运行“$ curl -v https://localhost:24466/”时收到“与localhost:24466相关的未知SSL协议错误”来自我的本地机器的请求(即切掉整个Heroku堆栈)。当DEBUG = True时,我的应用程序在Heroku上正常运行但在DEBUG = False时出现连接错误,我相信这是问题。
以下是我在settings.py中使用的相关设置:
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
SECURE_CONTENT_TYPE_NOSNIFF = True
SECURE_SSL_REDIRECT = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SECURE_BROWSER_XSS_FILTER = True
SESSION_COOKIE_SECURE = True
X_FRAME_OPTIONS = 'DENY'
CSRF_COOKIE_HTTPONLY = True
CSRF_COOKIE_SECURE = True
使用DEBUG = False进行部署是否有任何错误?
以下是“$ curl -v https://localhost:24466/”的完整结果:
~ $ curl -v https://localhost:24466/
* Hostname was NOT found in DNS cache
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 24466 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
[2016-12-01 16:49:39 +0000] [18] [CRITICAL] WORKER TIMEOUT (pid:23)
* Unknown SSL protocol error in connection to localhost:24466
* Closing connection 0
curl: (35) Unknown SSL protocol error in connection to localhost:24466
[2016-12-01 11:49:39 +0000] [23] [INFO] Worker exiting (pid: 23)
[2016-12-01 16:49:39 +0000] [33] [INFO] Booting worker with pid: 33