Nginx、uwsgi 和 flask 配置问题

Nginx, uwsgi and flask issue with configuration

到目前为止,我在 Ubuntu 18.04 远程服务器上有一个 Flask 应用程序 运行 uwsgi 和 nginx。这个应用程序由我网站的子域提供服务,监听端口 5002。我想添加一个新的 Flask 应用程序来监听端口 5003,但我一定是配置错误,然后一切都乱套了。现在这两个应用程序都不起作用。

app1 的服务器块

server {
        client_header_buffer_size 64k;
        large_client_header_buffers 4 64k;
        client_max_body_size 75M;
        server_name app.website1.eu;
        location / {
                include uwsgi_params;
                proxy_ignore_client_abort on;
                uwsgi_ignore_client_abort on;
                client_body_buffer_size 64K;
                client_max_body_size 8M;
                uwsgi_pass 127.0.0.1:5002;
                #uwsgi_pass unix:///home/pathto/website1.sock;
                uwsgi_buffer_size 64k;
                uwsgi_buffers 8 64k;
                uwsgi_busy_buffers_size 64k;
                uwsgi_read_timeout 300;
                uwsgi_send_timeout 300;
                uwsgi_connect_timeout 60;
        }
        listen 443 ssl; # managed by Certbot
        listen [::]:443 ssl;
        ssl_certificate /etc/letsencrypt/live/app.website1.eu/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/app.website1.eu/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
        if ($host = app.website1.eu) {
                return 301 https://$host$request_uri;
        } # managed by Certbot
        listen 80;
        listen [::]:80;
        server_name app.website1.eu;
        return 404; # managed by Certbot
}

app2 的服务器块

server {
        client_header_buffer_size 64k;
        large_client_header_buffers 4 64k;
        client_max_body_size 75M;
        server_name app.website2.eu;

        location / {
                include uwsgi_params;
                proxy_ignore_client_abort on;
                uwsgi_ignore_client_abort on;
                client_body_buffer_size 64K;
                client_max_body_size 8M;
                uwsgi_pass 127.0.0.1:5003;
                #uwsgi_pass unix:///home/pathto/website2.sock;
                uwsgi_buffer_size 64k;
                uwsgi_buffers 8 64k;
                uwsgi_busy_buffers_size 64k;
                uwsgi_read_timeout 300;
                uwsgi_send_timeout 300;
                uwsgi_connect_timeout 60;
        }

    listen 443 ssl; # managed by Certbot
    listen [::]:443 ssl;
    ssl_certificate /etc/letsencrypt/live/app.website2.eu/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/app.website2.eu/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = app.website2.eu) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
        listen 80;
        listen [::]:80;
        server_name app.website2.eu;
        return 404; # managed by Certbot
}

app1的ini文件

[uwsgi]
module = wsgi:app
master = true
processes = 10
enable-threads = true
uid=ilias
gid=www-data
socket=127.0.0.1:5002
#socket = website1.sock
chmod-socket = 666
vacuum = true
buffer-size=65536
harakiri=60
ignore-sigpipe=true
ignore-write-errors=true
disable-write-exception
post-buffering=1
logger=file:/home/path1/website1/uwsgierror.log
http-keepalive=3000
die-on-term = true

app2的ini文件

[uwsgi]
module = wsgi:app
master = true
processes = 10
enable-threads = true
uid=ilias
gid=www-data
socket=127.0.0.1:5003
#socket = website2.sock
chmod-socket = 666
vacuum = true
buffer-size=65536
harakiri=60
ignore-sigpipe=true
ignore-write-errors=true
disable-write-exception
post-buffering=1
logger=file:/home/path1/website2/uwsgierror.log
http-keepalive=3000
die-on-term = true

谁能帮帮我??

一如既往,这是一个文件夹权限问题。如果您在创建文件夹和创建虚拟环境的步骤中严格按照教程进行操作,那么一切都会很顺利。