简体   繁体   English

让我们用 Sails.js 加密

[英]Let's encrypt with Sails.js

Has anyone been able to use let's encrypt node module ( https://git.coolaj86.com/coolaj86/greenlock-express.js ) with Sails.js?有没有人能够在 Sails.js 中使用让我们加密节点模块( https://git.coolaj86.com/coolaj86/greenlock-express.js )? A little pointer would be helpful.一个小指针会有所帮助。

Yes, you can use greenlock-express.js for this to achieve SSL with LetsEncrypt directly within the Sails node environment.是的,您可以使用greenlock-express.js直接在Sails节点环境中通过LetsEncrypt实现 SSL。

The example below:下面的例子:

  1. Configures an HTTP express app using greenlock on port 80 that handles the redirects to HTTPS and the LetsEncrypt business logic.使用端口 80 上的 greenlock 配置 HTTP express 应用程序,该应用程序处理重定向到 HTTPS 和 LetsEncrypt 业务逻辑。
  2. Uses the greenlock SSL configuration to configure the primary Sails app as HTTPS on port 443.使用 greenlock SSL 配置将主要 Sails 应用程序配置为端口 443 上的 HTTPS。

Sample configuration for config/local.js : 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,
  },
};

Refer to the greenlock documentation for fine-tuning configuration detail, but the above gets an out-of-the-box LetsEncrypt working with Sails.请参阅 greenlock 文档以了解微调配置详细信息,但以上内容提供了一个开箱即用的 LetsEncrypt 与 Sails 一起使用。

Note also, that you may wish to place this configuration in somewhere like config/env/production.js as appropriate.另请注意,您可能希望将此配置适当地放置在config/env/production.js类的地方。

我不得不将绿色锁降级到版本 2。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM