HTTP Simple Proxy Daemon

1.0.5 · active · verified Tue Apr 21

http-simple-proxy is a Node.js-based reverse proxy daemon designed to allow multiple web applications to share the same HTTP(S) ports (e.g., 80 and 443). It functions as a front-end HTTP service, providing features such as reverse proxying, URL rewriting, HTTP redirects, SSL termination, serving static files, basic HTTP authentication, and WebSocket support. It is a simpler rewrite of the 'http-master' project, intended for less complex use cases where ease of setup is prioritized over the more robust features of its predecessor. The package is currently at version 1.0.5, indicating a stable but possibly not rapidly evolving codebase. It distinguishes itself by offering an all-in-one configuration for listening ports and flexible routing based on domain names, paths, and regular expressions, enabling HTTPS for non-SSL compatible backends.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to install http-simple-proxy and configure it to listen on ports 80 and 443, routing incoming requests to different backend services based on the domain name, including basic SSL configuration.

const HttpSimpleProxy = require('http-simple-proxy');
const httpSimpleProxy = new HttpSimpleProxy();

const config = {
  ports: {
    80: {
      router: {
        // Proxy requests for 'domain1.com' to port 3333
        "domain1.com": 3333,
        // Proxy requests for 'www.domain1.com' to port 3334
        "www.domain1.com": 3334,
        // Proxy all other requests on port 80 to a default backend on port 4080
        "*": 4080
      }
    },
    443: {
      router: {
        // Example for HTTPS, assuming SSL certificates are configured separately
        "secure.domain.com": 5000
      },
      ssl: {
        key: process.env.SSL_KEY_PATH ?? '', // Path to your SSL private key file
        cert: process.env.SSL_CERT_PATH ?? '' // Path to your SSL certificate file
      }
    }
  }
};

httpSimpleProxy.init(config, function(err) {
  if (err) {
    console.error('Proxy initialization error:', err);
  } else {
    console.info('http-simple-proxy started successfully');
    console.info('Listening on ports 80 and 443');
  }
});

view raw JSON →