繁体   English   中英

Django部署https + gunicorn和nginx

[英]Django deployment https + gunicorn and nginx

我坚持用nginx和gunicorn在aws上用django设置https。

我的配置是:

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/;

  }
}

使用端口8001 http可以正常工作:

 gunicorn configs.wsgi:application --bind 172.31.14.102:8001`

而不是域http://logitech.enterpriselist.com:8001/

但是我也想使用默认端口运行东西,但是当我运行时

gunicorn configs.wsgi:application --bind 172.31.14.102:80

它说地址已经被使用了!

当我打开http://logitech.enterpriselist.com/ ,也使用https,它会转到https://logitech.enterpriselist.com/但是它说网站具有重定向循环,因此我需要帮助进行排序。

您什么都没有告诉nginx应该将请求代理到gunicorn。 特别是,您需要proxy_pass指令和upstream部分。

另外,您也不想在端口80上运行gunicorn,因为那是nginx已经绑定到的端口。 这就是代理的目的。

gunicorn部署文档有一个可以正常运行的示例nginx配置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM