I am trying to set up letsencrypt (now greenlock apparently) for port forwarding with express.
I had this first issue that I solved with:
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
The issue is that, now, I get:
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
}
My app is like that right now:
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);
Apparently I cannot use ports 80 and 443 with nodeJS, but I cannot either use any other port with greenlock... What is the workaround?