【发布时间】:2015-06-02 07:26:31
【问题描述】:
我坚持使用 django 在 nginx 和 gunicorn 上设置 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
它说地址已经在使用中!
还有 https 当我打开 http://logitech.enterpriselist.com/ 时,它转到 https://logitech.enterpriselist.com/ 但它说网站有重定向循环,所以我需要帮助来排序。
【问题讨论】:
-
你有其他包含 Nginx 或与 Nginx 模拟链接的配置文件
-
是的,我已经将文件与启用文件夹站点的文件进行了simlinked
-
我不使用 gunicorn,但在我看来,您要求 nginx 在端口 80 上侦听,但同时您的 gunicorn 也在同一个端口上侦听。您要做的是在 8080 等高端口号上运行 gunicorn,然后让 nginx 在 80 上处理 http 请求,并在您的位置块中为“/”代理到 gunicorn。这有意义吗?
标签: python django ssl nginx gunicorn