无法通过HTTPS访问Node.js应用。

问题描述 投票:0回答:1

我有一个node.js程序,运行在3000端口。

在它的前面,我运行一个nginx反向代理。它在80端口上运行正常。我尝试用certbot安装一个证书。现在我有了证书,并设置我的代理服务器将所有非HTTPS流量重定向到HTTPS,并在443端口上将我的连接传递给我的应用程序。不知为何我的浏览器是挂起的,我不知道为什么。

在这里我添加了2个服务器块。

server {

    server_name mywebsite.at www.mywebsite.at;
    listen 443 ssl;

    ssl_certificate /etc/letsencrypt/live/mywebsite.at/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mywebsite.at/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
     }
}
server {

    server_name mywebsite.at www.mywebsite.at;
    listen 80;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
     }
}

在这种情况下,我可以输入 http:/mywebsite.at 但我无法进入 https:/mywebsite.at。. 它说 "无法到达网站"。知道为什么会出现这个错误吗?

我已经运行了 sudo nginx -t 没有错误。

node.js nginx reverse-proxy nuxt.js
1个回答
0
投票

我已经找到了问题的家伙。我的端口443没有打开。ufw allow 443 解决了这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.