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

http-proxied

v1.1.0

Published

Simple, zero-dependencies and zero-configuration command-line http proxy server.

Downloads

1

Readme

http-proxied

http-proxied is a simple, zero-dependencies and zero-configuration command-line http proxy server.
It is powerful enough for production usage, but it's simple and hackable enough to be used for testing, local development, and learning.

It is meant to be run in a docker container bound to a docker network.

Usage

Start transparent proxy forwarding all requests on :

npx http-proxied [port] [source:destination] [source:destination] ...

Docker example

A typical Docker scenario is having different containers not bound on host port but:

  • you need containers to resolve/reach to each other
  • you need to resolve/reach containers from host
  • you need all of this with proper hostnames

Create a test network:

docker network create test

Run 2 containers, attach them to network with wanted hostnames aliases, and fire a dummy webserver:

# first terminal, first webserver
docker run --name aaa --rm -ti --network=test --network-alias=aaa.com alpine sh
apk add npm curl
echo aaa > index.html
npx http-server -p 80 .

# second terminal, second webserver
docker run --name bbb --rm -ti --network=test --network-alias=bbb.com alpine sh
apk add npm curl
echo bbb > index.html
npx http-server -p 80 .

Both containers are happily running and can see themselves and each other:

docker exec -ti aaa curl aaa.com # aaa resolves aaa.com
docker exec -ti aaa curl bbb.com # aaa resolves bbb.com

docker exec -ti bbb curl aaa.com # bbb resolves aaa.com
docker exec -ti bbb curl bbb.com # bbb resolves bbb.com

Here the magic happens

Add to /etc/hosts containers hostnames:

vim /etc/hosts
127.0.0.1 localhost aaa.com bbb.com

Fire the proxy on port 80:

docker run --name proxy --rm -ti --network=test -p 80:80 node:14-alpine npx http-proxied 80 

⚠️ Remember:

  • the proxy must be attached on the network of containers with --network=test
  • the proxied request hostname must not resolve to same IP http-proxied is running on, or you will cause and endless loop! ⚠️