![](/img/trans.png)
[英]Cannot Redirect HTTP to HTTPS with EB Single Instance NodeJS NGINX Config
[英]NGINX and nodeJs works with http but not https
我有 NGINX 的這個配置:
server {
listen 80;
listen 443 ssl;
server_name rahim27.fr;
ssl_certificate /etc/letsencrypt/live/rahim27.fr/cert.pem;
ssl_certificate_key /etc/letsencrypt/live/rahim27.fr/privkey.pem;
error_log logs/error.log warn;
location / {
proxy_pass http://localhost:8080;
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;
}
}
這個基本的 NodeJS 服務器:
const http = require('http');
http.createServer(function (req, res) {
res.writeHead(200);
res.end("hello world\n");
}).listen(8080);
當我去http://rahim27.fr/時,我得到了我的hello world
但如果我嘗試https://rahim27.fr/我得到ERR_CONNECTION_RESET
,使用 curl 它給了我curl: (7) Failed to connect to rahim27.fr port 443: No route to host
和curl: (35) schannel: failed to receive handshake, SSL/TLS connection failed
。
服務器位於雲虛擬機中,我在雲儀表板和虛擬機本身中打開了所有端口。
SSL 證書是由 certbot 自動生成的。
我想要的是 :
hello world
我嘗試了什么:
最簡單的方法是刪除 ssl_certificate 和 ssl_certificate_key 行並使用負責自動管理 https 的 certbot。
我邀請您遵循以下易於遵循的說明:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.