运行flask app时出现Nginx 502 Bad Gateway错误,但可以手动运行

时间:2018-05-07 15:28:09

标签: python nginx flask

我有一个烧瓶应用程序,我可以通过从命令行执行python app.py来运行,并可以通过转到localhost:5000来查看它。我尝试使用gunicorn / nginx将其作为服务运行,并且有一个看起来像这样的nginx.conf文件

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;

sendfile            on;
tcp_nopush          on;
tcp_nodelay         on;
keepalive_timeout   65;
types_hash_max_size 2048;

include             /etc/nginx/mime.types;
default_type        application/octet-stream;

include /etc/nginx/conf.d/*.conf;

server {
    listen       80;
    server_name  myserver.com;
    root         /home/user/app/deviceapp/templates;

    location / {
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass http://127.0.0.1:8001;
        }
    }
}

我的nginx并不好。我收到了错误

2018/05/07 16:12:49 [error] 10419#0: *5 connect() failed (111: Connection refused) while connecting to upstream, client: 10.8.5.79, server: server.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8001/", host: "server.com"

以及502 Bad Gateway消息。我的nginx.conf中有什么东西是明显的罪魁祸首吗?

0 个答案:

没有答案