Nginx不是代理Gunicorn

Nginx不是代理Gunicorn,nginx,flask,gunicorn,Nginx,Flask,Gunicorn,我正在尝试使用Gunicorn和Nginx部署我的Flask项目,但我仍在努力 /etc/systemd/system/gunicorn3.service 然后我检查是否有任何问题,一切似乎都正常 >>sudo systemctl status gunicorn3 gunicorn3.service - Gunicorn service Loaded: loaded (/etc/systemd/system/gunicorn3.service; enabled; vendor

我正在尝试使用Gunicorn和Nginx部署我的Flask项目,但我仍在努力

/etc/systemd/system/gunicorn3.service 然后我检查是否有任何问题,一切似乎都正常

>>sudo systemctl status gunicorn3
gunicorn3.service - Gunicorn service
   Loaded: loaded (/etc/systemd/system/gunicorn3.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2020-01-17 20:25:01 UTC; 18min ago
 Main PID: 18451 (gunicorn)
    Tasks: 4 (limit: 4915)
   CGroup: /system.slice/gunicorn3.service
           ├─18451 /home/acelerathon_cima_grupo_3/chatbot-grupo-3/chatbot-cima/chatbot-cima-back/cimaenv/bin/python3 /home/acelerathon_cima_grupo_3/chatbo
           ├─18453 /home/acelerathon_cima_grupo_3/chatbot-grupo-3/chatbot-cima/chatbot-cima-back/cimaenv/bin/python3 /home/acelerathon_cima_grupo_3/chatbo
           ├─18454 /home/acelerathon_cima_grupo_3/chatbot-grupo-3/chatbot-cima/chatbot-cima-back/cimaenv/bin/python3 /home/acelerathon_cima_grupo_3/chatbo
           └─18456 /home/acelerathon_cima_grupo_3/chatbot-grupo-3/chatbot-cima/chatbot-cima-back/cimaenv/bin/python3 /home/acelerathon_cima_grupo_3/chatbo

Jan 17 20:25:01 acelerathon-cima-grupo-3 systemd[1]: Started Gunicorn service.
Jan 17 20:25:01 acelerathon-cima-grupo-3 gunicorn[18451]: [2020-01-17 20:25:01 +0000] [18451] [INFO] Starting gunicorn 19.9.0
Jan 17 20:25:01 acelerathon-cima-grupo-3 gunicorn[18451]: [2020-01-17 20:25:01 +0000] [18451] [INFO] Listening at: unix:cima.sock (18451)
Jan 17 20:25:01 acelerathon-cima-grupo-3 gunicorn[18451]: [2020-01-17 20:25:01 +0000] [18451] [INFO] Using worker: sync
Jan 17 20:25:01 acelerathon-cima-grupo-3 gunicorn[18451]: [2020-01-17 20:25:01 +0000] [18453] [INFO] Booting worker with pid: 18453
Jan 17 20:25:01 acelerathon-cima-grupo-3 gunicorn[18451]: [2020-01-17 20:25:01 +0000] [18454] [INFO] Booting worker with pid: 18454
Jan 17 20:25:01 acelerathon-cima-grupo-3 gunicorn[18451]: [2020-01-17 20:25:01 +0000] [18456] [INFO] Booting worker with pid: 18456
/etc/nginx/已启用站点/项目 然后我检查了错误

sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
所以这两项服务都还可以,现在当我访问时,我看到的是Nginx主页,而不是我的Flask应用程序主页


我不知道为什么在Nginx中没有代理

localhost
添加到
server\u name
指令。Nginx使用此指令为每个请求匹配服务器块,在您的情况下,
localhost
127.0.0.1
不匹配,因此默认情况下它是服务器。 也许这个例子有助于理解:

server {
        listen 127.0.0.1:80;
        server_name 127.0.0.1;
        return 200 "At 127.0.0.1\n";
}

server {
        listen 127.0.0.1:80;
        server_name localhost;
        return 200 "At localhost\n";
}

> curl -4 127.0.0.1:80
At 127.0.0.1
> curl -4 localhost:80
At localhost

谢谢,现在我有和你一样的输出,但是我的应用程序托管在VM中,我的url仍然指向Ngnix主页P.D.。为什么curl需要“-4”?
sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
server {
        listen 127.0.0.1:80;
        server_name 127.0.0.1;
        return 200 "At 127.0.0.1\n";
}

server {
        listen 127.0.0.1:80;
        server_name localhost;
        return 200 "At localhost\n";
}

> curl -4 127.0.0.1:80
At 127.0.0.1
> curl -4 localhost:80
At localhost