{"id":16075,"library":"http-simple-proxy","title":"HTTP Simple Proxy Daemon","description":"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.","status":"active","version":"1.0.5","language":"javascript","source_language":"en","source_url":"https://github.com/gusnips/http-simple-proxy","tags":["javascript","http","https","simple","proxy"],"install":[{"cmd":"npm install http-simple-proxy","lang":"bash","label":"npm"},{"cmd":"yarn add http-simple-proxy","lang":"bash","label":"yarn"},{"cmd":"pnpm add http-simple-proxy","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package primarily uses CommonJS `require()`. Direct ESM `import` is not officially supported and will likely fail without a transpiler or specific Node.js configuration.","wrong":"import { HttpSimpleProxy } from 'http-simple-proxy';","symbol":"HttpSimpleProxy","correct":"const HttpSimpleProxy = require('http-simple-proxy');"},{"note":"The imported `HttpSimpleProxy` is a class constructor and must be instantiated with `new` before use.","wrong":"const proxy = HttpSimpleProxy();","symbol":"HttpSimpleProxy","correct":"const proxy = new HttpSimpleProxy();"},{"note":"The `init` method expects a configuration object with a top-level `ports` key. Passing the ports configuration directly will lead to errors.","wrong":"proxy.init(portsConfig, callback);","symbol":"Configuration Object","correct":"proxy.init({ ports: { ... } }, callback);"}],"quickstart":{"code":"const HttpSimpleProxy = require('http-simple-proxy');\nconst httpSimpleProxy = new HttpSimpleProxy();\n\nconst config = {\n  ports: {\n    80: {\n      router: {\n        // Proxy requests for 'domain1.com' to port 3333\n        \"domain1.com\": 3333,\n        // Proxy requests for 'www.domain1.com' to port 3334\n        \"www.domain1.com\": 3334,\n        // Proxy all other requests on port 80 to a default backend on port 4080\n        \"*\": 4080\n      }\n    },\n    443: {\n      router: {\n        // Example for HTTPS, assuming SSL certificates are configured separately\n        \"secure.domain.com\": 5000\n      },\n      ssl: {\n        key: process.env.SSL_KEY_PATH ?? '', // Path to your SSL private key file\n        cert: process.env.SSL_CERT_PATH ?? '' // Path to your SSL certificate file\n      }\n    }\n  }\n};\n\nhttpSimpleProxy.init(config, function(err) {\n  if (err) {\n    console.error('Proxy initialization error:', err);\n  } else {\n    console.info('http-simple-proxy started successfully');\n    console.info('Listening on ports 80 and 443');\n  }\n});","lang":"javascript","description":"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."},"warnings":[{"fix":"Do not attempt to port `http-master` configurations directly. Refer to the http-simple-proxy README for specific syntax and supported features.","message":"http-simple-proxy is a simpler rewrite of `http-master`. Users migrating from `http-master` should expect significant differences in configuration options and available features, requiring a complete review and rewrite of proxy configurations.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Always validate your configuration object structure against the documentation examples. Start with simple rules and progressively add complexity. Use an object literal for the main configuration, and ensure `ports` is a top-level key within it.","message":"The configuration object for `init()` can become complex, especially with nested `ports` and `router` definitions. Pay close attention to the specific keys and their expected values (e.g., numbers for ports, strings for hosts, or objects for advanced rules).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure `ssl.key` and `ssl.cert` point to existing, readable SSL private key and certificate files (e.g., using `fs.readFileSync` or providing paths for an internal mechanism). Test SSL configuration thoroughly.","message":"Setting up SSL (HTTPS) requires providing valid `key` and `cert` paths within the `ssl` object for the respective port. Omitting or providing incorrect paths will prevent the HTTPS server from starting or cause certificate errors for clients.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Carefully review your wildcard domain rules. If you intend to catch both the root domain and its subdomains, use the `*?.domain.com` pattern. Test with various host headers to ensure correct routing.","message":"Wildcard domain matching behavior can be subtle. `*.domain.com` matches subdomains but not `domain.com` itself, while `*?.domain.com` matches both subdomains and `domain.com`.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Stop the conflicting process, or configure http-simple-proxy to listen on a different, available port.","cause":"Another process is already occupying the specified port (e.g., port 80 or 443).","error":"Error: listen EADDRINUSE: address already in use :::80"},{"fix":"Generate a new, valid SSL private key (e.g., 2048-bit or higher) and ensure it matches the certificate. Verify the paths to the key and certificate files are correct.","cause":"The provided SSL private key is invalid, corrupted, or too short (e.g., 512-bit key).","error":"Proxy error: Error: SSL_CTX_use_PrivateKey_file:EE_KEY_TOO_SMALL"},{"fix":"Double-check your configuration object structure. Ensure that `ports` is an object, and each port number within it contains an object that defines a `router` key.","cause":"The configuration object passed to `init()` is malformed, specifically lacking the expected `router` property within a port definition, or `ports` itself is missing.","error":"TypeError: Cannot read properties of undefined (reading 'router')"},{"fix":"Review your router configuration rules carefully. Ensure domain names match exactly (or use correct wildcards), target ports are correct, and the order of rules for complex routing is as intended (most specific rules should often come before more general ones).","cause":"Misconfiguration in the `router` rules, such as incorrect domain names, port numbers, or overlapping/incorrect regular expression patterns.","error":"Requests are not being routed to the expected backend."}],"ecosystem":"npm"}