首页 > 解决方案 > https 请求将发送到 80 端口

问题描述

我正在使用烧瓶 + nginx 对我的域的所有使用烧瓶的请求都将转到 80 端口,即使它是 https 连接我的域配置:

server {
    listen 80;
    server_name example.com;
    location / {
                proxy_pass http://127.0.0.1:8000;
    }
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;
    server_name example.com;
    ssl on;
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_protocols TLSv1 TLSv1.1 TLSV1.2;

    #ssl_dhparam /etc/nginx/dhparam.pem;
    location / {
                proxy_pass http://127.0.0.1:8000;
    }
}

所以,我发出重定向循环,在 access.log 中我看到,所有请求都将发送到 80 端口。我究竟做错了什么?证书来自 Let's Encrypt。

标签: nginxflask

解决方案


推荐阅读