[英]Django deployment https + gunicorn and nginx
I am stuck with setting the https with django on aws with nginx and gunicorn. 我坚持用nginx和gunicorn在aws上用django设置https。
my configuration is: 我的配置是:
server {
listen 80;
listen 443 ssl;
server_name logitech.enterpriselist.com;
rewrite ^ https://logitech.enterpriselist.com$request_uri? permanent;
root /home/ubuntu/git/elist/static/;
#` ssl on;
ssl_certificate /etc/ssl/elist.crt;
ssl_certificate_key /etc/ssl/elist.key;
location / {
# proxy_pass http://logitech.enterpriselist.com/;
}
location /static/ {
alias /home/ubuntu/git/elist/static/;
}
}
It is working fine with http with port 8001
: 使用端口
8001
http可以正常工作:
gunicorn configs.wsgi:application --bind 172.31.14.102:8001`
and not with domain http://logitech.enterpriselist.com:8001/
. 而不是域
http://logitech.enterpriselist.com:8001/
。
But I also want to run the things with the default port, but when I run 但是我也想使用默认端口运行东西,但是当我运行时
gunicorn configs.wsgi:application --bind 172.31.14.102:80
it says address already in use! 它说地址已经被使用了!
Also with https when I open http://logitech.enterpriselist.com/
, it goes to https://logitech.enterpriselist.com/
but it says website have redirect loop so I need help in sorting this. 当我打开
http://logitech.enterpriselist.com/
,也使用https,它会转到https://logitech.enterpriselist.com/
但是它说网站具有重定向循环,因此我需要帮助进行排序。
You haven't got anything to tell nginx it should be proxying requests to gunicorn. 您什么都没有告诉nginx应该将请求代理到gunicorn。 In particular, you need a
proxy_pass
directive and an upstream
section. 特别是,您需要
proxy_pass
指令和upstream
部分。
Also, you don't want to run gunicorn on port 80, since that is what nginx is already bound to. 另外,您也不想在端口80上运行gunicorn,因为那是nginx已经绑定到的端口。 That's what the proxy is for.
这就是代理的目的。
The gunicorn deployment docs have an example nginx configuration which works fine. gunicorn部署文档有一个可以正常运行的示例nginx配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.