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.
我正在家里安装测试服务器。 Web应用程序使用flask和python 3.6构建。为了使用nginx和gunicorn设置Web服务器,我遵循了Real Python Tutorial指南。这使用主管作为最终管理引擎。
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.
问题是我不知道从哪里开始寻找我的问题的原因。该应用程序有一个文件上传表单,如果服务器以主管启动,则在提交时会收到502错误的网关。但是,如果你直接启动gunicorn,应用程序没有问题,并按预期上传文件。
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.
任何关于如何调试它的帮助都会很棒。我不知道要分享哪些信息,所以请问,如果可以的话,我会得到你所能得到的信息。服务器是Ubuntu 16.04。
1 个解决方案
#1
0
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/
我花了几天时间处理类似的问题,但是使用了Django应用程序。基本上,Nginx的Bad Gateway问题与Nginx和Gunicorn之间的连接的权限问题有关。我建议你查看你的nginx.conf文件,并检查使用的用户。用户必须是管理系统的用户(具有执行/读取所需的权限)。另外,检查是否包含sites-enabled /中包含的配置文件(在我的情况下,我没有此目录,但直接覆盖了nginx.conf文件)。然后,检查您是否有@proxy_to_app,location /和上游块,如下所述: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.
希望这可以帮助!提示:检查/ var / log / nginx /中的nginx日志是否有任何错误消息。这有助于调试。
#1
0
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/
我花了几天时间处理类似的问题,但是使用了Django应用程序。基本上,Nginx的Bad Gateway问题与Nginx和Gunicorn之间的连接的权限问题有关。我建议你查看你的nginx.conf文件,并检查使用的用户。用户必须是管理系统的用户(具有执行/读取所需的权限)。另外,检查是否包含sites-enabled /中包含的配置文件(在我的情况下,我没有此目录,但直接覆盖了nginx.conf文件)。然后,检查您是否有@proxy_to_app,location /和上游块,如下所述: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.
希望这可以帮助!提示:检查/ var / log / nginx /中的nginx日志是否有任何错误消息。这有助于调试。