我正在尝试设置letsencrypt(现在显然是greenlock)以使用express进行端口转发。
我解决了第一个问题:
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3000
iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 3443
问题是,现在,我得到:
Fetching certificate for 'xxx' to use as default for HTTPS server...
[acme-v2] handled(?) rejection as errback:
Error: connect ECONNREFUSED 127.0.1.1:80
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1126:14)
Error loading/registering certificate for 'xxx':
Error: connect ECONNREFUSED 127.0.1.1:80
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1126:14) {
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.1.1',
port: 80
}
我的应用程序现在是这样的:
require("greenlock-express")
.create({
server: "https://acme-staging-v02.api.letsencrypt.org/directory",
email: "xxx@gmail.com", // The email address of the ACME user / hosting provider
agreeTos: true, // You must accept the ToS as the host which handles the certs
configDir: "~/.config/acme/", // Writable directory where certs will be saved
communityMember: true, // Join the community to get notified of important updates
telemetry: true, // Contribute telemetry data to the projec
store: require('greenlock-store-fs'),
approveDomains: ['xxx.xxx.xxx'],
// Using your express app:
// simply export it as-is, then include it here
app: require("../app.js")
//, debug: true
})
.listen(3000, 3443);
显然我不能将端口 80 和 443 与 nodeJS 一起使用,但我也不能将任何其他端口与 greenlock 一起使用……解决方法是什么?