如何使用gunicorn为django配置nginx?

时间:2016-10-14 12:52:14

标签: python django nginx

我已成功运行gunicorn并确认我的网站运行在localhost:8000上。但我不能让nginx正确。我的配置文件是这样的:

    server {
    listen 80;
    server_name 104.224.149.42;
    location / {
        proxy_pass http://127.0.0.1:8000;
        }
    }

104.224.149.42是外界的IP。

1 个答案:

答案 0 :(得分:0)

这样做

  • default
  • 移除/etc/nginx/sites-enabled/default

使用以下

创建/etc/nginx/sites-available/my.conf
server {
listen 80;
server_name 104.224.149.42;
location / {
    proxy_pass http://127.0.0.1:8000;
    }
}

然后sudo ln -s /etc/nginx/sites-available/my.conf /etc/nginx/sites-enabled/my.conf

  • 重新启动nginx

您必须配置static个文件和media个服务文件。