Home > Software design >  Can not reach Flask app served with uWSGI and Nginx
Can not reach Flask app served with uWSGI and Nginx

Time:03-07

I have a Flask back end that is functional without using uwsgi and nginx. I'm trying to deploy it on an EC2 instance with its front-end.

No matter what I do, I can't reach the back-end. I opened all the ports for testing purposes but that does not help.

Here's my uwsgi ini file:

[uwsgi]
module = main
callable = app
master = true
processes = 1
socket = 0.0.0.0:5000
vacuum = true
die-on-term = true

Then I use this command to start the app:

uwsgi --ini uwsgi.ini

The message returned is

WSGI app 0 (mountpoint='') ready in 9 seconds.
spawned uWSGI worker 1 (and the only) PID: xxxx

Then here is my Nginx conf file:

server {
        server_name my_name.com www.ny_name.com
        location / {
                    root /home/ubuntu/front_end/dist/;
        }
        location /gan {
                    proxy_pass https:localhost:5000/gan;
        }
        ## below https conf by certbot
}

If my understanding is correct, whenever a request reaches "my_name.com/gan..." it will be redirected to the localhost on the port 5000 where the back-end is started by uwsgi.

But I can't reach it. I'm trying to simply do a get request on "my_name.com/gan" on my browser (it should return a random image) but I get a 502 by nginx.

Important to note, the front-end works fine and I can access it on browser.

CodePudding user response:

My guess is that url is not in proper form

Try

proxy_pass http://0.0.0.0:5000;

  • Related