首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >502坏网关nginx/1.14.0 (Ubuntu)

502坏网关nginx/1.14.0 (Ubuntu)
EN

Server Fault用户
提问于 2020-04-12 07:15:52
回答 1查看 3.3K关注 0票数 0

我试图使用nginx & gunicorn部署django应用程序,但显示错误

代码语言:javascript
运行
复制
sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful




sudo systemctl status gunicorn.service

gunicorn.service - gunicorn service

   Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset:

   Active: active (running) since Sat 2020-04-11 21:19:19 IST; 11s ago

 Main PID: 16326 (gunicorn)


    Tasks: 4 (limit: 1689)

sudo systemctl status nginx

● nginx.service - A high performance web server and a reverse proxy server

   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)

   Active: active (running) since Sat 2020-04-11 04:54:18 IST; 18h ago

     Docs: man:nginx(8)

  Process: 1650 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfi

  Process: 1652 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exite

  Process: 1651 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (c

 Main PID: 1653 (nginx)

    Tasks: 9 (limit: 1689)

   CGroup: /system.slice/nginx.service

           ├─1653 nginx: master process /usr/sbin/nginx -g daemon on; master_process o

           ├─1654 nginx: worker process

           ├─1655 nginx: worker process

           ├─1656 nginx: worker process

           ├─1657 nginx: worker process

           ├─1658 nginx: worker process

           ├─1659 nginx: worker process

           ├─1660 nginx: worker process

           └─1661 nginx: worker process



Apr 11 04:54:18 wms systemd[1]: Starting A high performance web server and a reverse p

Apr 11 04:54:18 wms systemd[1]: Started A high performance web server and a reverse pr

已试过

代码语言:javascript
运行
复制
sudo systemctl stop nginx && sudo systemctl disable nginx && sudo systemctl enable nginx && sudo systemctl start nginx

/etc/nginx/站点-现有/iitians

代码语言:javascript
运行
复制
server {
       listen 80;
       server_name 192.95.37.123;
       location = /images/favicon.ico {access_log off;log_not_found off;}

       location /static/ {
         root /home/wms/iitians;
       }
       location /media/ {
         root /home/wms/iitians;
       }

       location / {
         include proxy_params;
         proxy_pass http://unix:/home/wms/iitians/iitians.sock;
       }
     }

/etc/system/system/gunicorn.service

代码语言:javascript
运行
复制
[Unit]
Description=gunicorn service
After=network.target

[Service]
User=wms
Group=www-data
WorkingDirectory=/home/wms/iitians/
ExecStart=/home/wms/iitiansenv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/wms/iitians/iitans.sock iitians.wsgi:application

[Install]
WantedBy=multi-user.target
EN

回答 1

Server Fault用户

发布于 2020-05-13 14:39:56

启动gunicorn之后,我建议您首先使用命令测试网关:

代码语言:javascript
运行
复制
sudo -u <nignx-user> curl --unix-socket /home/wms/iitians/iitians.sock http

代码语言:javascript
运行
复制
proxy_pass http://unix:/home/wms/iitians/iitians.sock;

应该是

代码语言:javascript
运行
复制
proxy_pass unix:/home/wms/iitians/iitians.sock;

部署Gunicorn

票数 1
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/1011961

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档