npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bc-port-vhoster

v0.1.17

Published

A simple HTTP vhost reverse proxy / port sharing implementation for node.js. Run multiple node HTTP servers (Domains, IP's) through one port.

Downloads

9

Readme

bc-port-vhoster

A simple HTTP vhost reverse proxy / port sharing implementation for node.js. Run multiple node HTTP servers (Domains, IP's) through one port.

This project implements a simple HTTP multi domain name / IP / directory HTTP reverse proxy for virtual hosting / port sharing. It simply does what a reverse proxy does combined with some mod_rewrite feature support.

This project also shows the power of node.js by being implemented in less than 100 lines of code.

PERFORMANCE NOTICE: This code has NOT been tested in production / high load environments. So be warned and evaluate it on your own before using it in production. Feedback is welcome! (It SHOULD be NOT LESS faster than the http-proxy module implementation.)

Prerequisites

Make sure:

  • node.js is installed (>= 0.8.*)
  • npm is installed

Installing


    [sudo] npm install -g bc-port-vhoster

Configuring

A valid configuration file for bc-port-vhoster is written in JSON notation as a single object that should provide three key/value pairs:

  • description (String) = Description, printed to the terminal on startup.
  • port (Number) = Source port (share port) to listen to (e.g. 80).
  • vhosts (Object) = Key ($ip OR $domain/port) / value (target $ip:$port/$path)-pairs of vhost-configurations.

Configuration example

The following configuration is a simple routing example. You can add more vhosts to the config object too:


    {
        "description": "Routing with port sharing on port 80 (HTTP) for some domains and paths...",
        "port": 80,
        "vhosts": {
            "www.aron-homberg.de": "127.0.0.1:8081",
            "aron-homberg.de": "127.0.0.1:8081",
            "example.com/downloads": "10.0.0.1:8080",
            "example.com/uploads": "10.0.0.2:8080/master/golive/upload"
        }
    }

Take a look at the examples directory for more inspiration.

Running

By default, bc-port-vhoster searches for a config file called port-vhoster.json in current working directory. If you want to use a different name, run bc-port-vhoster with the optional argument to name the config file:


    [sudo] bc-port-vhoster [$alternative-config-file.json]

You may need super-user permissions if you want bc-port-vhoster to listen to a port below 1024 (e.g. port 80).

Logging and running in stand-alone mode

If you're on a Unix/Linux/Mac OS X system you can run bc-port-vhoster in server mode easily:

Starting (e.g. start-vhoster.sh - don't forget to: chmod +x start-vhoster.sh!):

    #!/bin/sh
    echo "Starting bc-port-vhoster..."
    nohup bc-port-vhoster > bc-port-vhoster.out 2> bc-port-vhoster.err < /dev/null &

Stopping (e.g. stop-vhoster.sh - don't forget to: chmod +x stop-vhoster.sh!):

    #!/bin/sh
    echo "Stopping bc-port-vhoster..."
    kill $(ps aux | grep '[p]ort-vhoster' | awk '{print $2}')

For sure, server mode and logging may also be possible on Microsoft Windows platform but that's currently untested.