Nginx + gunicorn failed to reverse proxy successfully

< H2 > I deploy the flask application with nginx + gunicorn. < / H2 >

it is found that both nginx and gunicorn and flask work well, but they do not work together.
mainly because nginx listens to the public network port 80 is normal, but cannot reverse proxy to the gunicorn of port 5000

The command for

gunicorn is as follows

gunicorn wsgi-- bind 0.0.0.0 code 5000
I found that gunicorn + flask successfully runs on port 5000
and can successfully access the website in the server through port 5000 in the browser

. The settings for

nginx are as follows

/ etc/nginx/sites-enabled/web
the contents of the web file are as follows

server {
    listen 80;
    location / {
        proxy_pass http://localhost:5000;
    }
}

I successfully restarted nginx several times through service nginx restart .
use nginx-t to check whether the configuration is successful. The result is as follows:

nginx: the configuration file / etc/nginx/nginx.conf syntax is ok
nginx: configuration file / etc/nginx/nginx.conf test is successful

I use the browser to access ip without adding port (default port 80). The content of the web page is welcome to nginx
welcome-screen-e1450116630667.png

.

now I don"t know how to solve the problem

May.16,2021

the path to the nginx configuration file is generally not: / etc/nginx/nginx.conf

you can take a look at the path to the configuration file of conf in this command (open such as vim) / etc/init.d/nginx
after confirming that the configuration file has been modified, run / etc/init.d/nginx reload to try

Menu