【问题标题】:Certbot/LetsEncrypt HTTPS for NGINX reverse proxy not workingNGINX 反向代理的 Certbot/LetsEncrypt HTTPS 不起作用
【发布时间】:2019-03-04 08:09:37
【问题描述】:

我一直在尝试为我的网站设置 SSL,但无济于事。我在 Ubuntu 18.04 上使用 NGINX 作为两个 NodeJS Express Web 服务器的反向代理。我在these instructions 之后使用了 Certbot。但是,当尝试通过 HTTPS 访问我的网站时,我收到“无法访问网站”/“响应时间过长”错误。

这是我在 /etc/nginx/sites-available 中的 NGINX 配置:

server {

    listen [::]:443 ssl; # managed by Certbot
    listen 443 ssl;  # managed by Certbot
    server_name MYURL.com www.MYURL.com;

    ssl on;

    ssl_certificate /etc/letsencrypt/live/MYURL.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/MYURL.com/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

    access_log /var/log/nginx/MYURL.access.log;
    error_log /var/log/nginx/MYURL.error.log;

    client_max_body_size 50M;

    location / {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;

            proxy_pass https://localhost:3001;
    }
}

当我用listen 80; 替换listen [::]:443 ssllisten 443 ssl 行并尝试使用HTTP 访问该站点时,它工作正常。

知道可能是什么问题吗?


编辑:另外,我觉得我应该提到我的 UFW 状态有 22/tcp (LIMIT)、OpenSSH (ALLOW) 和 Nginx Full (ALLOW),以及它们的 v6 对应项

【问题讨论】:

  • 编辑:将 proxy_pass http://... 更改为 https://

标签: ssl nginx https


【解决方案1】:

原来 DigitalOcean 防火墙不允许 HTTPS 连接。我允许 HTTPS 并将 proxy_pass https://localhost:3001; 切换到 http://,现在一切正常!

【讨论】:

    猜你喜欢
    • 2020-08-30
    • 1970-01-01
    • 2018-12-12
    • 1970-01-01
    • 2019-06-15
    • 1970-01-01
    • 2019-03-23
    • 2019-06-05
    • 2019-09-04
    相关资源
    最近更新 更多