如何使用女服务员为烧瓶应用程序正确配置 NGINX for SSL

How to properly configure NGNIX for SSL for flask application using waitress

我有一个简单的烧瓶应用程序,我正在使用 waitress/nginx 到 serve/host

这些规则与 SSL 的预期一样有效

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    include snippets/number2.conf;
    include snippets/ssl-params.conf;

        root /var/www/html;

        index index.html index.htm index.nginx-debian.html;

        server_name https://exanple.com;
        location / {

            proxy_pass http://example.com:5000/;
            proxy_set_header X-Real-IP $remote_addr;


        }

}


server {
    listen 80;
    listen [::]:80;

    server_name domain;

    return 302 https://$server_name$request_uri;
}

但是,这些与 waitress/nginx 相同的应用程序无法正常工作。请注意,此服务器也是 运行 端口 8069 上的另一个应用程序。

    server {
    
        listen 443 ssl;
        listen [::]:443 ssl;
        include snippets/self-signed.conf;
        include snippets/ssl-params.conf;
    
    
           
    
            root /var/www/html;
        
    
            server_name ip.adress;
            rewrite ^/$ https://ip.adress;
    
    location / {
            proxy_pass http://ip.adress:8069;
            }
    
    
    }
    
    server {
        listen 80;
        listen [::]:80;
    
        server_name ip.adress;
            return 301 https://ip.adress$request_uri;
    
    
    }



server {
    listen 443 ssl;
    listen [::]:443 ssl;
    include snippets/number2.conf;
    include snippets/ssl-params.conf;

        root /var/www/html;

        index index.html index.htm index.nginx-debian.html;

        server_name https:/example.com;
        location / {

            proxy_pass http://example.com:5000/;
            proxy_set_header X-Real-IP $remote_addr;


        }

}


server {
    listen 80;
    listen [::]:80;

    server_name domain.com;

    return 302 https://$server_name$request_uri;
}

已尝试多种服务器规则组合,但此时我迷路了。

我想通了。对于遇到麻烦的其他人,我不得不使用反向代理。我listened to port 8001used a proxy port 5000用了header of Host $host。我还添加了 url_scheme='https' 到烧瓶应用程序。

https://docs.pylonsproject.org/projects/waitress/en/stable/reverse-proxy.html

    server {

    listen ip.adress:8001 ssl;
    include snippets/ssl-self.conf;
    include snippets/ssl-params.conf;



        root /var/www/html;



        index index.html index.htm index.nginx-debian.html;

        server_name ip.adress;

location / {
        proxy_pass http://ip.adress:5000;
        proxy_set_header        Host $host;

        }
}

下面的 proxy_pass http://ip.adress:5000;location / 中的主要重要行吗?