[英]Let's encrypt with Sails.js
有没有人能够在 Sails.js 中使用让我们加密节点模块( https://git.coolaj86.com/coolaj86/greenlock-express.js )? 一个小指针会有所帮助。
是的,您可以使用greenlock-express.js直接在Sails节点环境中通过LetsEncrypt实现 SSL。
下面的例子:
config/local.js
示例配置:
// returns an instance of greenlock.js with additional helper methods
var glx = require('greenlock-express').create({
server: 'https://acme-v02.api.letsencrypt.org/directory'
, version: 'draft-11' // Let's Encrypt v2 (ACME v2)
, telemetry: true
, servername: 'domainname.com'
, configDir: '/tmp/acme/'
, email: 'myemail@somewhere.com'
, agreeTos: true
, communityMember: true
, approveDomains: [ 'domainname.com', 'www.domainname.com' ]
, debug: true
});
// handles acme-challenge and redirects to https
require('http').createServer(glx.middleware(require('redirect-https')())).listen(80, function () {
console.log("Listening for ACME http-01 challenges on", this.address());
});
module.exports = {
port: 443,
ssl: true,
http: {
serverOptions: glx.httpsOptions,
},
};
请参阅 greenlock 文档以了解微调配置详细信息,但以上内容提供了一个开箱即用的 LetsEncrypt 与 Sails 一起使用。
另请注意,您可能希望将此配置适当地放置在config/env/production.js
类的地方。
我不得不将绿色锁降级到版本 2。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.