SVR.JS - a web server running on Node.JS https://svrjs.org
Find a file
2024-11-12 19:56:50 +01:00
.github/workflows Update main.yml 2024-06-22 09:16:06 +02:00
.husky build: make the commit-msg Git hook executable 2024-09-01 22:02:31 +02:00
assets feat: add options related to disabling configuration file saving, and use them in the "dev" script 2024-11-09 13:31:31 +01:00
coreAssets chore: remove "version" property from "svrjs.core.json" and create SVR.JS Core documentation 2024-11-10 16:38:06 +01:00
src fix: revert the forbidden path checking middleware to using the current working directory 2024-11-12 19:56:50 +01:00
templates feat: add options related to disabling configuration file saving, and use them in the "dev" script 2024-11-09 13:31:31 +01:00
tests fix: use a function that normalizes the webroot 2024-11-12 19:28:19 +01:00
.gitignore feat: add SVR.JS Core 2024-11-10 15:42:56 +01:00
commitlint.config.js build: add husky and commitlint for commit validation 2024-09-01 21:39:58 +02:00
esbuild.config.js feat: add TypeScript declarations to SVR.JS Core 2024-11-12 18:40:10 +01:00
eslint.config.js feat: add TypeScript declarations to SVR.JS Core 2024-11-12 18:40:10 +01:00
jest.config.js Rewritten SVR.JS from scratch - the build system for the new SVR.JS is set up, but the source is just placeholders. 2024-08-23 17:05:10 +02:00
LICENSE Add LICENSE file 2024-08-26 08:00:04 +02:00
lint-staged.config.js build: configure lint-staged to lint TypeScript declaration files (.d.ts) 2024-11-12 19:07:16 +01:00
nodemon.json build: add rebuilding SVR.JS when the source code changes when the "dev" script is executed 2024-11-09 13:20:02 +01:00
package-lock.json feat: add TypeScript declarations to SVR.JS Core 2024-11-12 18:40:10 +01:00
package.json feat: add TypeScript declarations to SVR.JS Core 2024-11-12 18:40:10 +01:00
prettier.config.js build: add Prettier configuration 2024-09-01 21:53:53 +02:00
README.md docs: clarify that the type definition file is only on a single file 2024-11-12 19:00:38 +01:00
svrjs.core.json chore: remove "version" property from "svrjs.core.json" and create SVR.JS Core documentation 2024-11-10 16:38:06 +01:00
svrjs.json fix: rename "Nightly-GitNext" to "Nightly-GitMain" 2024-11-10 20:43:12 +01:00
tsconfig.json feat: add TypeScript declarations to SVR.JS Core 2024-11-12 18:40:10 +01:00

SVR.JS - a web server running on Node.JS
It's free as in freedom, scalable, secure, and configurable.

Static Badge Website Docker Pulls GitHub Repo stars X (formerly Twitter) Follow Mastodon Follow


Features

Static file handling

  • Static file serving (even above 2GB)
  • Directory listing serving
  • Protection against path traversal
  • Content-Range support (for non-HTML static files; also for HTML files from SVR.JS 3.15.1)
  • Serving from web root different than SVR.JS installation directory

Security

  • HTTPS support
  • HTTP/2 support
  • Built-in block list
  • Protection against HTTP authentication brute force attacks (from SVR.JS 3.4.8; enabled by default)
  • Ability to hide server version
  • OCSP stapling support (from SVR.JS 3.4.9)

Configuration and customization

  • Configurability via config.json file
  • Expandability via server-side JavaScript and mods
  • Ability to serve non-standard error pages
  • URL rewriting engine
  • Event driven architecture powered by Node.JS, along with clustering.

Compression and content delivery

  • Brotli, gzip and Deflate HTTP compression (Brotli supported since SVR.JS 3.4.11)
  • SNI (Server Name Indication) support
  • ETag support (from SVR.JS 3.6.1)
  • Reverse proxy functionality (requires reverse-proxy-mod SVR.JS mod)
  • Forward proxy functionality (requires forward-proxy-mod SVR.JS mod)

Authentication and access control

  • HTTP basic authentication

Gateway interfaces

  • CGI (Common Gateway Interface) support (requires RedBrick mod)
  • SCGI (Simple Common Gateway Interface) support (requires OrangeCircle mod)
  • JSGI (JavaScript Gateway Interface) support (requires YellowSquare mod)
  • PHP support (PHP-CGI with RedBrick mod or PHP-FPM with GreenRhombus mod)

Additional functionality

  • Logging
  • Ability to display IP addresses, from which originally request was made (from reverse proxies; via X-Forwarded-For)

Building SVR.JS

To build SVR.JS, you need Node.JS 18.0.0 or newer.

Before building SVR.JS, install the npm packages using this command:

npm install

After installing the packages, build SVR.JS with this command:

npm run build 

After running the command, you will get bundled SVR.JS script, around with built-in utilities and assets in the dist directory. You will also get a zip archive in out directory, that can be installed using SVR.JS installer. Additionally, you will get the SVR.JS Core package contents in the core directory, which you can publish by running npm publish in the core directory.

Installation (built from source)

To install SVR.JS you just built from the source code, you can install it via SVR.JS installer for GNU/Linux or manually.

If you want to install SVR.JS manually, you can read the server documentation.

If you want to install via SVR.JS installer for GNU/Linux, run this command:

curl -fsSL https://downloads.svrjs.org/installer/svr.js.installer.linux.20240509.sh > /tmp/installer.sh && sudo bash /tmp/installer.sh

You will be then prompted about the type of installation. Choose option “2” to install SVR.JS from the zip archive, and type in the path to the zip archive (hint: it is in the out directory).

After typing the path, you may be prompted to install dependencies via GNU/Linux distributions package manager. Proceed with the installation of dependencies.

After installation, SVR.JS should be listening at http://localhost.

SVR.JS documentation

You can read the SVR.JS documentation to get information on how to use SVR.JS.

npm scripts

  • To build SVR.JS along with the zip archive, run npm run build.
  • To check SVR.JS code for errors with ESLint, run npm run lint.
  • To fix and beautify SVR.JS code with ESLint and Prettier, run npm run lint:fix.
  • To run SVR.JS from the "dist" folder, run npm start.
  • To test SVR.JS itself, run npm run dev. This removes existing configuration.
  • To perform unit tests with Jest, run npm test.

File structure

The file structure for SVR.JS source code looks like this:

  • .husky - Git hooks
  • assets - files to copy into dist folder and to the archive
  • core - contains SVR.JS Core
  • coreAssets - files to copy into core folder
  • dist - contains SVR.JS, assets, and SVR.JS utiltiies
  • generatedAssets - assets generated by the build script
  • out - contains SVR.JS zip archive
  • src - contains SVR.JS source code
    • index.js - SVR.JS entry point
    • core.js - SVR.JS Core entry point
    • core.d.ts - SVR.JS Core type definitions (the type definition only on a single file)
    • extraScripts - SVR.JS extra scripts (each script has a single file)
    • handlers - handlers for servers
    • middleware - built-in middleware for servers
    • res - resources
    • utils - utility functions
  • templates - EJS templates for build script to use
  • tests - Jest unit tests
    • middleware - tests for middleware
    • utils - unit tests for utility functions
  • commitlint.config.js - commitlint configuration
  • esbuild.config.js - the build script
  • eslint.config.js - ESLint configuration
  • jest.config.js - Jest configuration
  • lint-staged.config.js - lint-staged configuration
  • prettier.config.js - Prettier configuration
  • svrjs.json - SVR.JS version, name, documentation URL, and statistics server collection endpoint URL

Contribute

See SVR.JS contribution page for details.

License

This project is licensed under the MIT/X11 License - see the LICENSE file for details.