我有一个数字海洋液滴启动和运行,并在我的仪表板159.xxx.xxx.xx,并与nano / etc / nginx / sites-available / hello_world ip我有这个configuration文件:
server { listen 80; server_name 159.xxx.xxx.xx; location / { proxy_pass https://127.0.0.1:8000; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /static/ { alias /root/dev/hello_world/staticfiles/; } }
当我在浏览器中访问https://159.xxx.xxx.xx:80 /时,Firefox中出现ERR_SSL_PROTOCOL_ERROR ,Chrome出现ERR_SSL_PROTOCOL_ERROR 。
无论我是否使用gunicorn运行或不使用gunicorn hello_world.wsgi --bind 127.0.0.1:8000
为什么我得到这个错误,我能做些什么来解决它? 预先感谢您的耐心。
您收到SSL协议错误,因为nginx只在端口80上提供HTTP,而不是HTTPS。 但是,您错误地在您的URL的开头input了https。
在https上启动简单应用程序
# gunicorn -w 4 --certfile=/etc/pki/nginx/server.crt --keyfile=/etc/pki/nginx/server.key test_app:app 2016-03-06 18:59:28 [8545] [INFO] Starting gunicorn 18.0 2016-03-06 18:59:28 [8545] [INFO] Listening at: https://127.0.0.1:8000 (8545) 2016-03-06 18:59:28 [8545] [INFO] Using worker: sync 2016-03-06 18:59:28 [8550] [INFO] Booting worker with pid: 8550 2016-03-06 18:59:28 [8551] [INFO] Booting worker with pid: 8551 2016-03-06 18:59:28 [8552] [INFO] Booting worker with pid: 8552 2016-03-06 18:59:28 [8553] [INFO] Booting worker with pid: 8553
configurationnginx
server { listen *:8090; server_name www.example.net; location / { proxy_pass https://127.0.0.1:8000; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
testinggunicorn
# curl -k https://127.0.0.1:8000/ Hello, World!
testingnginx
# curl http://www.example.net:8090/ Hello, World!
所以我认为你的问题是与gunicorn应用程序设置