Docker failed to deploy flask successfully (nginx+gunicorn)

flask+nginx+gunicorn+supervisor is deployed in docker mode. After starting with supervisor, visiting http://127.0.0.1 can only see the welcome interface of nginx, but not the interface of flask

.

the related code is as follows:

app.py

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello_world():
    return "Hello World!"

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=80)

flask.conf

server {
   listen  80;
   server_name 120.0.0.1;

   location  /  {
      proxy_pass   http://127.0.0.1:8001;
   }
  }
  

supervisor.conf

[program:nginx-app]
command = /usr/sbin/nginx -g "daemon off;"
stdout_logfile = /var/log/supervisor/nginx_stdout.log
stdout_logfile_maxbytes = 10MB
stderr_logfile = /var/log/supervisor/nginx_error.log
stderr_logfile_maxbytes = 10MB

[program:app-gunicorn]
command = /usr/local/bin/gunicorn -w 4 -b 127.0.0.1:8001 app:app
directory = /app
stdout_logfile = /var/log/supervisor/gunicorn_out.log
stdout_logfile_maxbytes = 10MB
stderr_logfile = /var/log/supervisor/gunicorn_error.log
stderr_logfile_maxbytes = 10MB

gunicorn log:

[2018-12-12 03:29:48 +0000] [8824] [INFO] Starting gunicorn 19.9.0
[2018-12-12 03:29:48 +0000] [8824] [INFO] Listening at: http://127.0.0.1:8001 (8824)
[2018-12-12 03:29:48 +0000] [8824] [INFO] Using worker: sync
[2018-12-12 03:29:48 +0000] [8829] [INFO] Booting worker with pid: 8829
[2018-12-12 03:29:49 +0000] [8830] [INFO] Booting worker with pid: 8830
[2018-12-12 03:29:49 +0000] [8831] [INFO] Booting worker with pid: 8831
[2018-12-12 03:29:49 +0000] [8834] [INFO] Booting worker with pid: 8834

after starting supervisor, you can only see the nginx welcome interface and solve ~

.
Feb.15,2022

has not used gunicorn. However, in the impression that the nginx configuration corresponds to the flask listening port, it is declared in location instead of listen,. Maybe you can try to swap the port to see if the server block is not configured correctly in the


nginx configuration. Write server_name _; or listen 80 default_server;


get the answer elsewhere, because the default configuration file / etc/nginx/sites-enabled/default is not deleted, resulting in duplicate snooping on port 80.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3a7f7-2b996.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3a7f7-2b996.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?