https express - localhost无法正常工作

时间:2017-07-28 12:52:50

标签: node.js express https

我正在尝试在我的应用中实施greenlock-express。这就是我做的。

 var lex = require('greenlock-express').create({
  server: 'staging',
  challengeType: 'http-01',
  challenges: { 'tls-sni-01': require('le-challenge-fs').create({ webrootPath: '/tmp/acme-challenges' }) },
  store: require('le-store-certbot').create({ webrootPath: '/tmp/acme-challenges' }),
  approveDomains: approveDomains
});

var approveDomains = function(opts, certs, cb) {

  if (certs) { 
    opts.domains = certs.altnames; 
  } else {
    opts.domains = ['www.domain.com', 'domain.com']; 
    opts.emails = 'email@domain.com';
    opts.agreeTos = true;  
  }

  cb(null, { options: opts, certs: certs });
} 

require('http').createServer(lex.middleware(require('redirect-https')())).listen(8080, function () {
  console.log("Listening for ACME http-01 challenges on", this.address());
});

// express app settings, router, etc...

require('https').createServer(lex.httpsOptions, lex.middleware(app)).listen(443, function () {
  console.log("Listening for ACME tls-sni-01 challenges and serve app on", this.address());
});

所以我按照文档中的所有步骤进行操作,并且没有返回任何错误。所以我做对了。

当我尝试访问localhost:8080时,问题就发生了,我将其重定向到https://localhost,但该页面为空白。我不知道为什么。

我检查了端口是否被nestat -an阻止,并且他们的状态都设置为listening

不太清楚发生了什么事。

谢谢你, 马克

0 个答案:

没有答案