@@ -262,6 +262,8 @@ Any URL like `/year/month/day/anything/` will redirect to this article (and link
|
|||||||
the directory where will be located the git repo with templates and articles
|
the directory where will be located the git repo with templates and articles
|
||||||
* `view_engine` (default: ejs)
|
* `view_engine` (default: ejs)
|
||||||
the Express view engine used to render pages from templates
|
the Express view engine used to render pages from templates
|
||||||
|
* `rate_limit` (default: 100)
|
||||||
|
number of requests allowed in a time-frame of 15 minutes
|
||||||
* `access_log` (default: access.log)
|
* `access_log` (default: access.log)
|
||||||
log file where to save access requests (empty to disable)
|
log file where to save access requests (empty to disable)
|
||||||
* `error_log` (default: error.log)
|
* `error_log` (default: error.log)
|
||||||
|
|||||||
Generated
+6
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gitblog.md",
|
"name": "gitblog.md",
|
||||||
"version": "1.2.6",
|
"version": "1.2.7",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -3130,6 +3130,11 @@
|
|||||||
"vary": "~1.1.2"
|
"vary": "~1.1.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"express-rate-limit": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-dhT57wqxfqmkOi4HM7NuT4Gd7gbUgSK2ocG27Y6lwm8lbOAw9XQfeANawGq8wLDtlGPO1ZgDj0HmKsykTxfFAg=="
|
||||||
|
},
|
||||||
"extend": {
|
"extend": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gitblog.md",
|
"name": "gitblog.md",
|
||||||
"version": "1.2.7",
|
"version": "1.2.8",
|
||||||
"description": "A static blog using Markdown pulled from your git repository.",
|
"description": "A static blog using Markdown pulled from your git repository.",
|
||||||
"main": "src/server.js",
|
"main": "src/server.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
"crypto": "^1.0.1",
|
"crypto": "^1.0.1",
|
||||||
"ejs": "^2.6.2",
|
"ejs": "^2.6.2",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
|
"express-rate-limit": "^5.0.0",
|
||||||
"fa-diagrams": "^1.0.3",
|
"fa-diagrams": "^1.0.3",
|
||||||
"mathjax-node": "^2.1.1",
|
"mathjax-node": "^2.1.1",
|
||||||
"ncp": "^2.0.0",
|
"ncp": "^2.0.0",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ const app = express();
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const pjson = require('../package.json');
|
const pjson = require('../package.json');
|
||||||
|
const rateLimit = require('express-rate-limit');
|
||||||
|
|
||||||
app.enable('trust proxy');
|
app.enable('trust proxy');
|
||||||
|
|
||||||
@@ -122,6 +123,13 @@ module.exports = (config) => {
|
|||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//rate limit for safer server
|
||||||
|
const limiter = rateLimit({
|
||||||
|
windowMs: 15 * 60 * 1000, // 15 minutes
|
||||||
|
max: config['rate_limit']
|
||||||
|
});
|
||||||
|
app.use(limiter);
|
||||||
|
|
||||||
//log request at result end
|
//log request at result end
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
if (config['access_log']) {
|
if (config['access_log']) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"host": "",
|
"host": "",
|
||||||
"data_dir": "data",
|
"data_dir": "data",
|
||||||
"view_engine": "ejs",
|
"view_engine": "ejs",
|
||||||
|
"rate_limit": 100,
|
||||||
"access_log": "access.log",
|
"access_log": "access.log",
|
||||||
"error_log": "error.log",
|
"error_log": "error.log",
|
||||||
"modules": {
|
"modules": {
|
||||||
|
|||||||
Reference in New Issue
Block a user