我已经设置了我的快递和节点应用程序使用我的letsencrypt ssl证书
var options = {
key: fs.readFileSync('/etc/letsencrypt/live/example.com/privkey.pem'),
cert: fs.readFileSync('/etc/letsencrypt/live/example.com/cert.pem')
};
// Create an HTTP service.
http.createServer(app).listen(3060);
// Create an HTTPS service identical to the HTTP service.
https.createServer(options, app).listen(3061);
我可以通过domain.com访问我的API(在nginx中访问端口80)
但如果我点击https://example.com(端口443)
,我无法联系到它但是,如果我打开端口3061并请求https://example.com:3061并且它可以正常使用SSL
,我就可以访问它我的问题是,如何设置nginx以正确地将端口443上的请求转发到我的服务器端口3061上用于SSL。
如果我的应用正在处理它,我是否需要按照其他地方的建议包含证书信息?
我的nginx配置是这样的:
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://localhost:3060;
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 {
listen 443 ssl;
server_name example.com;
location / {
proxy_pass https://localhost:3061;
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;
}
}
谢谢