Reputation: 79
I am setting up a test server at home. The web app is built with flask and python 3.6. For setting up the web server with nginx and gunicorn I followed the guide Real Python Tutorial. This use supervisor for the final management engine.
The problem is I don't know where to start looking to find the cause of my issue. The app has a file upload form which when submitted gets 502 bad gateway if the server is start with supervisor. But if you start gunicorn directly the app works with no issues and uploads the files as expected.
Any help on how to debug this would be great. I don't know what information to share so just ask and I will get what ever you if I can. The server is Ubuntu 16.04.
Upvotes: 3
Views: 1421
Reputation: 11
I spent some days with a similar issue, but with a Django app. Basically, the Bad Gateway problems with Nginx have to do with permission issues for the connection between Nginx and Gunicorn. I suggest you look at your nginx.conf file, and check the user used. The user must be the one that administrates the system (have the necessary permisions for executing/reading). Also, check that you include the configuration files contained in sites-enabled/ (in my case I don't have this directory, but directly overwrote the nginx.conf file). Then, check that you have the @proxy_to_app, location / , and upstream blocks like explained here https://rukbottoland.com/blog/django-gunicorn-nginx-supervisor/
Hope this helps! Tip: check the nginx logs at /var/log/nginx/ for any error message. That helps debugging.
Upvotes: 1