Egg https 配置
1 2 3 4 5 6 7 8 9 10 11
| config.cluster = { listen: { path: "", port: 443 }, https: { key: key, cert: cert, ciphers: 'ECDHE-RSA-AES128-GCM-SHA256' } }
|
node-modules/egg-cluster/lib/app_worker.js
1 2 3 4
| if (httpsOptions.ciphers) { httpsOptions.ciphers = httpsOptions.ciphers; }
|
Egg 安全配置
node-modules/egg-cluster/lib/app_worker.js
1 2 3 4 5 6 7 8 9 10
| var tls = require('tls');
tls.CLIENT_RENEG_LIMIT = 0; tls.CLIENT_RENEG_WINDOW = 0;
server.headersTimeout = 9 * 1000; server.maxHeadersCount = 2000;
|
静态资源添加响应头
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| const initStatic = app.config.coreMiddleware.indexOf('static'); const uedStatic = app.middleware.uedStatic(); app.middleware.splice(initStatic, 0, uedStatic);
module.exports = () => { return async function uedStatic(ctx, next) { if (ctx.request.url.indexOf("/js/") || ctx.request.url.indexOf("/css/" || ctx.request.url.indexOf("/img/"))) { ctx.response.set({ "响应头key": "响应头Value" }) } await next(); } }
|
参考