This repository has been archived on 2024-09-12. You can view files and clone it, but cannot push or open issues or pull requests.
svrjs-website/source/mods.md

6.8 KiB

title date
Download official SVR.JS mods 2023-12-21 20:42:00

SVR.JS has these official SVR.JS mods:

  • Berno - SSI (Server-Side Includes) engine (not maintained). Latest version: 1.1.0
  • easy-waf integration - WAF (web application firewall) mod. Latest version: 1.2.4
  • forward-proxy-mod - mod, that enables SVR.JS to do forward proxy functionality. Latest version: 1.0.0
  • GreenRhombus - FastCGI (Fast Common Gateway Interface) client. Latest version: 1.0.7
  • Next.js integration - mod, that enables SVR.JS to serve Next.js applications. Latest version: 1.0.0
  • OrangeCircle - SCGI (Simple Common Gateway Interface) client. Latest version: 1.2.1
  • RedBrick - CGI (Common Gateway Interface) engine. Latest version: 2.6.2
  • reverse-proxy-mod - mod, that enables SVR.JS to do reverse proxy functionality. Latest version: 1.1.4
  • YellowSquare - JSGI (JavaScript Gateway Interface) engine. Latest version: 1.1.3

All of these mods are licensed under MIT/X11 license.

Notes

Berno

Current version of Berno allows SSI only in .shtml files. Berno includes parts from very old version of RedBrick (1.x) to handle "exec" SSI directives.

easy-waf integration

NOTICE: Using a WAF (Web Application Firewall) is no subsitute for web application security, because attacker will find a way to bypass the WAF.

Configuration file is easywaf-config.json inside SVR.JS installation directory. Configuration is passed to easy-waf. You can see documentation at its GitHub page. This mod requires easy-waf Node.JS module.

From easy-waf-integration 1.2.0, there is also additional mailConfig property, which is an object with those values:

  • serverConfig - server configuration object passed to nodemailer
  • from - source e-mail address
  • to - destination e-mail address

These versions support sending email in case of blocked request (requires nodemailer module).

From easy-waf-integration 1.2.0, there is support of pre-block and post-block hooks in easywaf-hooks.js inside SVR.JS installation directory.

Example easywaf-hooks.js code:

//EasyWAF hooks. For more information read the easy-waf documentation in GitHub.

function preBlockHook(req, moduleInfo, ip) {
  //You can add exceptions for WAF. In this example we do add exception for "cgi-bin".
  if (moduleInfo.name == 'directoryTraversal' && req.url.match(/\/cgi-bin(?:$|[#?/])/)) return false;
  //We're also adding XSS exception for YaBB forum software to prevent false positives
  if (moduleInfo.name == 'xss' && /\/YaBB\.(?:pl|cgi)(?:$|[?#])/.test(req.url) && /(?:(\\?)|[;&])action=(?:post2|modify2|imsend2|cdchatupdate|ajxmessage)($|[;&#])/.test(req.url)) return false;
}

function postBlockHook(req, moduleInfo, ip) {
  //You can, for example send an e-mail notification or log it into file.
}

module.exports = {postBlockHook: postBlockHook, preBlockHook: preBlockHook};

From easy-waf-integration 1.2.4, there are additional configuration properties:

  • maxRequestCheckedSize - maximum size of the request body (in bytes) to be checked. Default is 65536 (64 KiB).
  • maxRequestCheckedSizeStrict - option to enable strict request body limits. If the limits are exceeded, then the server will return a 413 Content Too Large error. Default is false.

If you're using SVR.JS behind a reverse proxy, you need to configure trustProxy property in easy-waf configuration.

Example easywaf-config.json file:

{
  "modules": {
    "xss": {
      "excludePaths": "/^\\/(?:git\\/)?(?:(?!\\.git).)*\\.git\\/|^\\/(?:(?:navbar-)?logo|powered).png$/"
    },
    "noSqlInjection": {
      "excludePaths": "/^\\/(?:git\\/)?(?:(?!\\.git).)*\\.git\\//"
    },
    "crlfInjection": {
      "excludePaths": "/^\\/(?:git\\/)?(?:(?!\\.git).)*\\.git\\//"
    }
  },
  "mailConfig": {
    "serverConfig": {
      "host": "localhost",
      "port": 25,
      "secure": false,
      "ignoreTLS": true
    },
    "from": "svrjs@localhost",
    "to": "sysadmin@localhost"
  }
}

View the change log.

forward-proxy-mod

Notes are in the SVR.JS documentation. View the change log.

GreenRhombus

Notes are in the SVR.JS documentation. View the change log.

Next.js integration

The webroot (wwwroot config.json property) serves as a Next.js application directory. It's recommended to set the owner of the Next.js application directory (around with all the files in it) as the user, on which SVR.JS is running (usually "svrjs"). Setting a NODE_ENV environment variable to development in SVR.JS configuration enables Next.js development server.

It's also recommended to forbid the access to ".env" file and ".git" directories, in case Next.js integration mod fails to load. You can set up nonStandardCodes config.json property like this:

{
  "nonStandardCodes": [
    {
      "scode": 403,
      "regex": "/^\\/\\.env(?:\\.local|\\.production)?(?:$|[#?])/"
    },
    { 
      "scode": 403,
      "regex": "/^\\/\\.git/"
    },
    ...other non-standard codes...
  ],
  ...other config.json properties...
}

View the change log.

OrangeCircle

Notes moved to SVR.JS documentation. View the change log.

RedBrick

Notes moved to SVR.JS documentation. View the change log.

reverse-proxy-mod

Notes moved to SVR.JS documentation. View the change log.

YellowSquare

Notes moved to SVR.JS documentation. View the change log.

Download older versions of mods

You can download older versions of SVR.JS mods.

Download deprecated mods

WARNING! Deprecated SVR.JS mods are not maintained anymore, and may have NO DOCUMENTATION available and have SECURITY VULNERABILITIES.

You can download deprecated SVR.JS mods.