Reputation: 2727
I am using the following server script to run both http, https servers and redirect all http requests to https.
When I access the server both locally and remotely from IP addresses, the requests redirect to https and api works with an unsecure warning.
But when I access the same routes via domain, I get "Site cannot be Reached"
error.
Although, accessing http://example.com/test-route
redirects to https://example.com/test-route
, I am still getting Site can't be reached
error.
import http from 'http';
import https from 'https';
import redirectHttps from 'redirect-https';
import greenlock from 'greenlock';
import app from '../app';
var le = greenlock.create({
server: 'staging', // using https://acme-v01.api.letsencrypt.org/directory in prod
configDir: 'certs',
approveDomains: (opts, certs, cb) => {
if (certs) {
opts.domains = ['example.com']
} else {
opts.email = '[email protected]',
opts.agreeTos = true;
}
cb(null, {
options: opts,
certs: certs
});
},
});
http.createServer(le.middleware(redirectHttps())).listen(80, function() {
console.log("Server Running On http @ port " + 80);
});
https.createServer(le.httpsOptions, le.middleware(app)).listen(443, function() {
console.log("Server Running On https @ port " + 443);
});
Upvotes: 2
Views: 2403
Reputation: 77122
There's a number of reasons that this could be happening, and a lot has been updated in the library since you posted this question.
I've spent a lot of time recently updating the documentation and examples:
I'd suggest taking a look at the video tutorial:
And check each of the items in the troubleshooting section. For reference:
Double check the following:
http-01
challenges
ifconfig
show a public address (good)? or a private one - 10.x, 192.168.x, etc (bad)?dns-01
challenge?version: 'draft-11'
version: 'v01'
email
to a valid addressdig MX example.com
for '[email protected]'
)approveDomains
to real domainsdig +trace A example.com; dig +trace www.example.com
for [ 'example.com', 'www.example.com' ]
)configDir
to a writeable location (test with touch ~/acme/etc/tmp.tmp
)sudo
or setcap
server
value in productionPlease post an issue at the repository if you're still having trouble and I'll do my best to help you sort things out. Make sure to upgrade to the latest version because it has better debug logging.
Upvotes: 1