- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在我的本地系统中设置 ssl。我正在使用带有 sails js 应用程序的 Windows 机器。
这是我做的配置。
/**
* Production environment settings
* (sails.config.*)
*
* What you see below is a quick outline of the built-in settings you need
* to configure your Sails app for production. The configuration in this file
* is only used in your production environment, i.e. when you lift your app using:
*
* ```
* NODE_ENV=production node app
* ```
*
* > If you're using git as a version control solution for your Sails app,
* > this file WILL BE COMMITTED to your repository by default, unless you add
* > it to your .gitignore file. If your repository will be publicly viewable,
* > don't add private/sensitive data (like API secrets / db passwords) to this file!
*
* For more best practices and tips, see:
* https://sailsjs.com/docs/concepts/deployment
*/
// returns an instance of greenlock.js with additional helper methods
const glx = require('greenlock-express').create({
server: 'https://acme-staging-v02.api.letsencrypt.org/directory',
version: 'draft-12', // Let's Encrypt v2 (ACME v2)
telemetry: true,
configDir: 'D:\\cert\\localhost',
email: 'xuz@gmail.com',
agreeTos: true,
servername: 'localhost.com',
domains: ['localhost', 'www.localhost'],
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 = {
/**************************************************************************
* *
* Tell Sails what database(s) it should use in production. *
* *
* (https://sailsjs.com/config/datastores) *
* *
**************************************************************************/
datastores: {
/***************************************************************************
* *
* Configure your default production database. *
* *
* 1. Choose an adapter: *
* https://sailsjs.com/plugins/databases *
* *
* 2. Install it as a dependency of your Sails app. *
* (For example: npm install sails-mysql --save) *
* *
* 3. Then set it here (`adapter`), along with a connection URL (`url`) *
* and any other, adapter-specific customizations. *
* (See https://sailsjs.com/config/datastores for help.) *
* *
***************************************************************************/
default: {
adapter: 'sails-mysql',
url: 'mysql://root:gs8jh3kj3w48xudf@35.197.96.87:3306/fulfil_db'
// adapter: 'sails-mysql',
// url: 'mysql://user:password@host:port/database',
//--------------------------------------------------------------------------
// /\ To avoid checking it in to version control, you might opt to set
// || sensitive credentials like `url` using an environment variable.
//
// For example:
// ```
// sails_datastores__default__url=mysql://admin:myc00lpAssw2D@db.example.com:3306/my_prod_db
// ```
//--------------------------------------------------------------------------
/****************************************************************************
* *
* More adapter-specific options *
* *
* > For example, for some hosted PostgreSQL providers (like Heroku), the *
* > extra `ssl: true` option is mandatory and must be provided. *
* *
* More info: *
* https://sailsjs.com/config/datastores *
* *
****************************************************************************/
// ssl: true,
}
},
models: {
/***************************************************************************
* *
* To help avoid accidents, Sails automatically sets the automigration *
* strategy to "safe" when your app lifts in production mode. *
* (This is just here as a reminder.) *
* *
* More info: *
* https://sailsjs.com/docs/concepts/models-and-orm/model-settings#?migrate *
* *
***************************************************************************/
migrate: 'safe'
/***************************************************************************
* *
* If, in production, this app has access to physical-layer CASCADE *
* constraints (e.g. PostgreSQL or MySQL), then set those up in the *
* database and uncomment this to disable Waterline's `cascadeOnDestroy` *
* polyfill. (Otherwise, if you are using a databse like Mongo, you might *
* choose to keep this enabled.) *
* *
***************************************************************************/
// cascadeOnDestroy: false,
},
/**************************************************************************
* *
* Always disable "shortcut" blueprint routes. *
* *
* > You'll also want to disable any other blueprint routes if you are not *
* > actually using them (e.g. "actions" and "rest") -- but you can do *
* > that in `config/blueprints.js`, since you'll want to disable them in *
* > all environments (not just in production.) *
* *
***************************************************************************/
blueprints: {
shortcuts: false
},
/***************************************************************************
* *
* Configure your security settings for production. *
* *
* IMPORTANT: *
* If web browsers will be communicating with your app, be sure that *
* you have CSRF protection enabled. To do that, set `csrf: true` over *
* in the `config/security.js` file (not here), so that CSRF app can be *
* tested with CSRF protection turned on in development mode too. *
* *
***************************************************************************/
security: {
/***************************************************************************
* *
* If this app has CORS enabled (see `config/security.js`) with the *
* `allowCredentials` setting enabled, then you should uncomment the *
* `allowOrigins` whitelist below. This sets which "origins" are allowed *
* to send cross-domain (CORS) requests to your Sails app. *
* *
* > Replace "https://example.com" with the URL of your production server. *
* > Be sure to use the right protocol! ("http://" vs. "https://") *
* *
***************************************************************************/
cors: {
allRoutes: true,
allowOrigins: '*',
allowCredentials: false
}
},
/***************************************************************************
* *
* Configure how your app handles sessions in production. *
* *
* (https://sailsjs.com/config/session) *
* *
* > If you have disabled the "session" hook, then you can safely remove *
* > this section from your `config/env/production.js` file. *
* *
***************************************************************************/
session: {
/***************************************************************************
* *
* Production session store configuration. *
* *
* Uncomment the following lines to finish setting up a package called *
* "@sailshq/connect-redis" that will use Redis to handle session data. *
* This makes your app more scalable by allowing you to share sessions *
* across a cluster of multiple Sails/Node.js servers and/or processes. *
* *
* *
* > While @sailshq/connect-redis is a popular choice for Sails apps, many *
* > other compatible packages (like "connect-mongo") are available on NPM. *
* > (For a full list, see https://sailsjs.com/plugins/sessions) *
* *
***************************************************************************/
// adapter: '@sailshq/connect-redis',
// url: 'redis://user:password@localhost:6379/databasenumber',
//--------------------------------------------------------------------------
// /\ OR, to avoid checking it in to version control, you might opt to
// || set sensitive credentials like this using an environment variable.
//
// For example:
// ```
// sails_session__url=redis://admin:myc00lpAssw2D@bigsquid.redistogo.com:9562/0
// ```
//
//--------------------------------------------------------------------------
/***************************************************************************
* *
* Production configuration for the session ID cookie. *
* *
* Tell browsers (or other user agents) to ensure that session ID cookies *
* are always transmitted via HTTPS, and that they expire 24 hours after *
* they are set. *
* *
* Note that with `secure: true` set, session cookies will _not_ be *
* transmitted over unsecured (HTTP) connections. Also, for apps behind *
* proxies (like Heroku), the `trustProxy` setting under `http` must be *
* configured in order for `secure: true` to work. *
* *
* > While you might want to increase or decrease the `maxAge` or provide *
* > other options, you should always set `secure: true` in production *
* > if the app is being served over HTTPS. *
* *
* Read more: *
* https://sailsjs.com/config/session#?the-session-id-cookie *
* *
***************************************************************************/
cookie: {
// secure: true,
maxAge: 24 * 60 * 60 * 1000 // 24 hours
}
},
/**************************************************************************
* *
* Set up Socket.io for your production environment. *
* *
* (https://sailsjs.com/config/sockets) *
* *
* > If you have disabled the "sockets" hook, then you can safely remove *
* > this section from your `config/env/production.js` file. *
* *
***************************************************************************/
sockets: {
onlyAllowOrigins: []
/***************************************************************************
* *
* Uncomment the `onlyAllowOrigins` whitelist below to configure which *
* "origins" are allowed to open socket connections to your Sails app. *
* *
* > Replace "https://example.com" etc. with the URL(s) of your app. *
* > Be sure to use the right protocol! ("http://" vs. "https://") *
* *
***************************************************************************/
// onlyAllowOrigins: [
// 'https://example.com',
// 'https://staging.example.com',
// ],
/***************************************************************************
* *
* If you are deploying a cluster of multiple servers and/or processes, *
* then uncomment the following lines. This tells Socket.io about a Redis *
* server it can use to help it deliver broadcasted socket messages. *
* *
* > Be sure a compatible version of @sailshq/socket.io-redis is installed! *
* > (See https://sailsjs.com/config/sockets for the latest version info) *
* *
* (https://sailsjs.com/docs/concepts/deployment/scaling) *
* *
***************************************************************************/
// adapter: '@sailshq/socket.io-redis',
// url: 'redis://user:password@bigsquid.redistogo.com:9562/databasenumber',
//--------------------------------------------------------------------------
// /\ OR, to avoid checking it in to version control, you might opt to
// || set sensitive credentials like this using an environment variable.
//
// For example:
// ```
// sails_sockets__url=redis://admin:myc00lpAssw2D@bigsquid.redistogo.com:9562/0
// ```
//--------------------------------------------------------------------------
},
/**************************************************************************
* *
* Set the production log level. *
* *
* (https://sailsjs.com/config/log) *
* *
***************************************************************************/
log: {
level: 'debug'
},
http: {
serverOptions: glx.httpsOptions,
/***************************************************************************
* *
* The number of milliseconds to cache static assets in production. *
* (the "max-age" to include in the "Cache-Control" response header) *
* *
***************************************************************************/
cache: 365.25 * 24 * 60 * 60 * 1000 // One year
/***************************************************************************
* *
* Proxy settings *
* *
* If your app will be deployed behind a proxy/load balancer - for example, *
* on a PaaS like Heroku - then uncomment the `trustProxy` setting below. *
* This tells Sails/Express how to interpret X-Forwarded headers. *
* *
* This setting is especially important if you are using secure cookies *
* (see the `cookies: secure` setting under `session` above) or if your app *
* relies on knowing the original IP address that a request came from. *
* *
* (https://sailsjs.com/config/http) *
* *
***************************************************************************/
// trustProxy: true,
},
/**************************************************************************
* *
* Lift the server on port 80. *
* (if deploying behind a proxy, or to a PaaS like Heroku or Deis, you *
* probably don't need to set a port here, because it is oftentimes *
* handled for you automatically. If you are not sure if you need to set *
* this, just try deploying without setting it and see if it works.) *
* *
***************************************************************************/
host: '127.0.0.1',
port: 443,
ssl: true,
/**************************************************************************
* *
* Configure an SSL certificate *
* *
* For the safety of your users' data, you should use SSL in production. *
* ...But in many cases, you may not actually want to set it up _here_. *
* *
* Normally, this setting is only relevant when running a single-process *
* deployment, with no proxy/load balancer in the mix. But if, on the *
* other hand, you are using a PaaS like Heroku, you'll want to set up *
* SSL in your load balancer settings (usually somewhere in your hosting *
* provider's dashboard-- not here.) *
* *
* > For more information about configuring SSL in Sails, see: *
* > https://sailsjs.com/config/*#?sailsconfigssl *
* *
**************************************************************************/
// ssl: undefined,
lifejacket: {
// Disabled by default. (e.g. for local dev)
// So you'll want to override this in your config/env/production.js file,
// setting it to `true`.
ensureHttps: true
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// If you don't already have the conventional `sails.config.custom.baseUrl` set,
// then uncomment the following `host` config. This must be set manually if `ensureHttps`
// is enabled.
// > Should be provided as a string, like `foo.example.com`.
// host: 'mysweetsite.com',
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
}
};
当我在命令下启动时,它会显示这样的图像 但是当我在浏览器中运行这个应用程序时 https://localhost然后它显示错误。
错误:
[gl/index.js] gl.getCertificates called for localhost with certs for NONE
[gl/index.js] gl.approveDomains called with certs for NONE and options:
[gl/index.js] { domain: 'localhost',
domains: [ 'localhost' ],
certs: null,
certificate: {},
account: {},
wildname: '*.' }
[gl/index.js] gl getting from disk or registering new
[le-store-certbot]
[le-store-certbot]
[greenlock/lib/core.js] checkAsync failed to find certificates
[le-store-certbot] success reading arg.accountsDir
[le-store-certbot] regrs.length 1
[le-store-certbot] accountId: 7deec612c26a9f3163c582e4ea6a972d
[greenlock/lib/core.js] calling greenlock.acme.getCertificateAsync localhost [ 'localhost' ]
[acme-v2] DEBUG get cert 1
[acme-v2] accounts.create
[acme-v2] agreeToTerms
[acme-v2] accounts.create JSON body:
{ protected:
'eyJub25jZSI6IjAwMDJOU2o2eXpYRlB6SWhMekRLT1lwc1R6bTdlcXhtMWVBMzBNdFJqZ3VFSlU4IiwiYWxnIjoiUlMyNTYiLCJ1cmwiOiJodHRwczovL2FjbWUtc3RhZ2luZy12MDIuYXBpLmxldHNlbmNyeXB0Lm9yZy9hY21lL25ldy1hY2N0IiwiandrIjp7Imt0eSI6IlJTQSIsIm4iOiJ4ZXB4b2RyempSdi1nUERpaUg3ZFhFQklYR3pvXy16bXkyNzNDeEN6TFRIUkx4ZFBpb29idXRtNzZHbkxpRzV4QzN0eHoyS1k2Tk1qSXNERWJRNk1mM1BCc3RLVnp1V01HLWxvZ0ducDZqOXFyVHVpSloyRk1VYkQwRVk2R3R6ZzRNQzVRNnJqM1BqUDIyOXNnQjJ3UWlGLWtNMzBHSU9KOE14T1c0RGhlMHRaQ1JpVHpnQmt0Qy1EUFRMUGdDMTRYR0RfTC10QVN6OW5SUlBGbDZNdGljWjkwQktNbG16OUFQalNiajBpclloV3VJVmNyN1l6SnhBakFod015OE9BRVFjbTJXbldjN3YyZXVPa2RZSkZpNEpEelM5cmppZWlSZTItR05kNmFpbHdhdzZVdkRnZVFFY2N3VllqblVJcUdGUlFMNE55RlZQVEZlT2lDT1FGelEiLCJlIjoiQVFBQiJ9fQ',
payload:
'eyJ0ZXJtc09mU2VydmljZUFncmVlZCI6dHJ1ZSwib25seVJldHVybkV4aXN0aW5nIjpmYWxzZX0',
signature:
'niurbbdEwbyPPXdLEWw_Qi1iQSHQ2otsqZPUEUAZ4HN3BNDo2ugknJMQdvPEzMrsfyntxMyX6hqiM5sgYcbaPX5TErolPebmITXC3lqgBn8nZaMx2JInqD0s8OQM71l-N95PqAmbOpTykGPaEASwN95acm47gQdbjLu6nBsnF6sfzFghRDTVhk8xpGhUTqhKjQ7vIrH6QlpPVi8N5WTabfCQDWeaNCFjq6vKiCvbfjFPmLZn2junDwAe4utIpuP3FqZYMlCvXFCmr_o7qyyQZWxWWZbajHJO75HBkrqKx_fbI5ogj3wuLikddQmzDqPARV0F8coEaYqmQsfh24h43A' }
[DEBUG] new account location:
https://acme-staging-v02.api.letsencrypt.org/acme/acct/11074181
{ statusCode: 200,
body:
{ key:
{ kty: 'RSA',
n:
'xepxodrzjRv-gPDiiH7dXEBIXGzo_-zmy273CxCzLTHRLxdPioobutm76GnLiG5xC3txz2KY6NMjIsDEbQ6Mf3PBstKVzuWMG-logGnp6j9qrTuiJZ2FMUbD0EY6Gtzg4MC5Q6rj3PjP229sgB2wQiF-kM30GIOJ8MxOW4Dhe0tZCRiTzgBktC-DPTLPgC14XGD_L-tASz9nRRPFl6MticZ90BKMlmz9APjSbj0irYhWuIVcr7YzJxAjAhwMy8OAEQcm2WnWc7v2euOkdYJFi4JDzS9rjieiRe2-GNd6ailwaw6UvDgeQEccwVYjnUIqGFRQL4NyFVPTFeOiCOQFzQ',
e: 'AQAB' },
contact: [ 'mailto:baj9032@gmail.com' ],
initialIp: '103.238.110.39',
createdAt: '2019-09-20T08:07:38Z',
status: 'valid' },
headers:
{ server: 'nginx',
date: 'Fri, 20 Sep 2019 08:11:39 GMT',
'content-type': 'application/json',
'content-length': '551',
connection: 'close',
'cache-control': 'public, max-age=0, no-cache',
link:
'<https://acme-staging-v02.api.letsencrypt.org/directory>;rel="index"',
location:
'https://acme-staging-v02.api.letsencrypt.org/acme/acct/11074181',
'replay-nonce': '00027sSdL_GbUp842Yw5P-69vfX0wI1vzkxBJGo6_9o6jwY',
'x-frame-options': 'DENY',
'strict-transport-security': 'max-age=604800' },
request:
{ uri:
Url {
protocol: 'https:',
slashes: true,
auth: null,
host: 'acme-staging-v02.api.letsencrypt.org',
port: null,
hostname: 'acme-staging-v02.api.letsencrypt.org',
hash: null,
search: null,
query: null,
pathname: '/acme/new-acct',
path: '/acme/new-acct',
href: 'https://acme-staging-v02.api.letsencrypt.org/acme/new-acct' },
method: 'POST',
headers:
{ 'Content-Type': 'application/jose+json',
'Content-Length': 1155 } } }
[acme-v2] DEBUG get cert 1
[greenlock/lib/core.js] setChallenge called for 'localhost'
[DEBUG] waitChallengeDelay 500
[acme-v2] handled(?) rejection as errback:
Error: connect ECONNREFUSED 127.0.0.1:80
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1097:14)
Error loading/registering certificate for 'localhost':
{ Error: connect ECONNREFUSED 127.0.0.1:80
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1097:14)
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 80 }
最佳答案
localhost
不允许您可以使用带有本地证书的 Let's Encrypt 的 Greenlock,但不是特别是主机名 localhost
.
改为使用 myapp.local.mydomain.com
等域(可能具有 IP 地址 127.0.0.1),其中一个插件用于 Let's Encrypt DNS 验证:
或者为您的 DNS 提供商编写一个插件:
对于您的 CI/CD 环境,请务必使用 Let's Encrypt Staging URL。
在生产环境中,确保将证书放在已安装的卷(并相应地设置 Greenlock 配置)。
如果您不这样做,您将达到证书生成的 Let's Encrypt 的速率限制,因为您每次启动临时 docker 实例时都会获得新证书(例如,当您更改环境变量时云提供商的控制面板)。
关于sails.js - https 在 sailsjs 的本地主机中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58025774/
在 sailsjs 1.0@beta 中,我有一个模型链接到带有 mysql-sails@beta 适配器的 mysql 表中的 View 。 模型配置如下: attributes: { id
我有一个独立的操作,我使用 CloudSDK 通过单击按钮从我的前端调用它,我得到了我的值,但该操作不会重定向到 View 。我已在成功退出中将 responseType 指定为 View ,但这似乎
sails.sockets.rooms()和sails.sockets.socketRooms()均已弃用 在文档中: This method is deprecated. Please keep t
我尝试使用以下方法在 Controller 操作中获取发布数据: req.body.name 但是不起作用 最佳答案 您可以尝试先检索全部内容来访问它们 function(req, res, next
我一直在尝试按照文档和 StackOverflow 上的说明为我的应用程序加载自定义配置,但失败了。 我在中创建了一个新文件 /config/application.js 内容: module.exp
我对两个 Nodejs 和 sails 都很陌生。我正在尝试在一个 Action 中创建两个模型。我的问题是如何处理两个查询中可能发生的错误。 当前代码: new: function (req, re
所以我的问题是我想将任何请求记录到我的 sails 应用程序。基本上我已经解决了一个问题,即我无法记录请求的参数。 myRequestLogger: function(req, res, next)
是否可以动态更新 sails.config 对象,而无需重新升起 sails 来应用这些更改? 我希望动态更新sails.config.policies 在我的 bootstrap.js 中我已经设置
假设我有一个很长的任务,当有人连接到 InitializeDB 时,该任务就开始运行。 (当然,将来会获得授权,但暂时不考虑)。 'post /initializeDB':'OrderControll
问题 所以我正在编辑一个 CRUD 应用程序以在删除之前进行确认,并创建了一个 JavaScript 函数来执行此操作,但我在 cmd 和“显示”页面上收到以下错误 error: Sending 50
我了解到放置在资源中的静态文件将可以直接在浏览器中访问。但是执行此操作后,我的静态文件无法访问。 最后,结果发现静态文件没有编译到隐藏文件夹(.tmp/public)中。我手动将所有文件复制到这个隐藏
sails.js 框架不支持事务。在 GitHub 问题中,他们谈论 transaction()。但是不适合在一个事务中编写多个查询。 所以我认为一种解决方案是使用 node-mysql 模块。但我认
好吧,我(天真地)试图让 bull 在 sails 应用程序中工作:最终我希望有一个队列,我可以根据传入路线向其中添加/删除/检查任务。 现在,据我所知,要创建一个可在全局范围内运行的排队系统,我必须
我正在开发一个 Sails 应用程序,对于我的单元测试,我需要在 ./test/bootstrap.test.js 和 ./test/unit/controllers/*.test.js 中使用一些变
我一直在努力更好地了解如何在 SailsJS 中设置外键。我目前正在开展一个类(class)项目,我的小组需要创建一个评估系统,其中包含教师和学生的个人资料以查看结果。我在网上看到了一些例子,但我看到
我想创建一条动态路线。我创建了一个名为用户的 API。我需要可以访问/users/:nameofuser,就像自动创建的用户/id。 如何在这种类型的 url 中获取用户名,并执行 Controlle
我有一个模型帖子: // Post.js attributes:{ name: {type:"string"}, users: { collection: 'user', via: '
我的 Sailsjs 应用程序中有以下具有多对多关系的模型: 事件.js: attributes: { title : { type: 'string', required: true }, de
我正在使用 Sails v0.10.5。 我创建了三个模型,它们之间存在关联。存在一个Candidate 模型、一个Evaluator 模型和一个Rating 模型,评估者通过该模型对候选人进行评分。
我的 Sails 应用程序中有用户模型,当然它有密码。因此,当我创建新用户时,Sails 会使用包含新创建用户的所有数据(包括哈希密码)的 json 进行响应。有没有办法阻止 Sails 输出某些字段
我是一名优秀的程序员,十分优秀!