nginx+gunicorn+supervisor+flask @ centos

时间:2023-12-17 13:46:32

/etc/nginx/conf.d/default.conf

server {
listen 80 default_server;
server_name 127.0.0.1; #charset koi8-r; #access_log logs/host.access.log main; # Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf; location / {
root /home/www/my_flask;
index index.html index.htm;
try_files $uri @gunicorn_proxy;
} location @gunicorn_proxy {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:8000;
}

  

/etc/supervisord.conf

[program:my_flask]
command=/home/www/my_flask/venv/bin/gunicorn runserver:app -c /home/www/my_flask/gunicorn.conf
directory=/home/www/my_flask
user=root
autostart=true
autorestart=true
stdout_logfile=/home/www/my_flask/logs/gunicorn_supervisor.log

/home/www/my_flask/gunicorn.conf

workers=3
bind = '127.0.0.1:8000'