我有一台现成的特快服务器。和两个网络应用程序与它一起工作。
快件服务器位于端口: 1111
我已经为我的nginx服务器创建了两个letsencrypt,我将它与app.domain.com和domain.com的前端站点一起使用,它工作得很好。
关键是没有到达后端,因为它也必须是ssl。但是..。如何为后端设置有效的ssl?我的意思是,我不能用letsencrypt来做这件事,因为它是一个后端服务器,而且没有ssl。
我尝试使用在快递服务器中为domain.com生成的相同证书,基本上使用从其他站点获取的代码。
// Dependencies
const fs = require('fs');
const http = require('http');
const https = require('https');
const express = require('express');
const app = express();
// Certificate
const privateKey = fs.readFileSync('/etc/letsencrypt/live/yourdomain.com/privkey.pem', 'utf8');
const certificate = fs.readFileSync('/etc/letsencrypt/live/yourdomain.com/cert.pem', 'utf8');
const ca = fs.readFileSync('/etc/letsencrypt/live/yourdomain.com/chain.pem', 'utf8');
const credentials = {
key: privateKey,
cert: certificate,
ca: ca
};
app.use((req, res) => {
res.send('Hello there !');
});
// Starting both http & https servers
const httpServer = http.createServer(app);
const httpsServer = https.createServer(credentials, app);
httpServer.listen(80, () => {
console.log('HTTP Server running on port 80');
});
httpsServer.listen(443, () => {
console.log('HTTPS Server running on port 443');
});但是它是随机的,很多时候请求超时是因为它花了很长时间,而另一些时候,它很奇怪。但是现在它突然停止工作了,所以我不知道在那里该做什么。
我必须使用哪种类型的证书?
自签名的服务器被chrome拒绝,如果express节点服务器运行在ip中而不是域中,我不知道如何生成letsencrypt服务器。
发布于 2020-06-07 21:48:26
好吧,问题是我的nginx虚拟主机。我创建了一个虚拟主机api.domain.com
server
{
listen 443;
listen [::]:443;
server_name api.domain.com;
location /
{
proxy_pass https://127.0.0.1:1111;
}
}然后跑
sudo certbot --nginx -d api.domain.com然后它开始起作用
https://stackoverflow.com/questions/62251597
复制相似问题