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

@cloud-cli/px

v4.1.7

Published

Reverse Proxy

Downloads

250

Readme

PX

Reverse proxy to map local services and external http(s) domains

Usage

Use it with Cloudy

// cloudy.conf.mjs

import proxy from '@cloud-cli/px';

export default { proxy };

API

All proxies have the following properties:

| Options | Description | | --------------- | ---------------------------------------------------------------------------------------------------- | | domain | Required. entrypoint for reverse proxy | | target | Required. Any target address, can be local or remote | | cors | handle CORS request on proxy level. See notes below! | | redirect | if request comes as http, redirect to https | | redirectUrl | if provided, issues a Location header and terminates with status 302 instead of proxying a request | | headers | comma separated headers to set in the outbound connection, e.g. authorisation headers | | authorization | matches incoming request headers against this value. If strings match, requests can continue. |

Add a proxy to a local service

cy proxy.add --domain "foo.example.com" --target "http://localhost:1234"

Remove a proxy

cy proxy.remove --domain "foo.example.com"

Get details of a proxy

cy proxy.get --domain "foo.example.com"

List proxies

cy proxy.list

List registered domains

cy proxy.domains

Reload all configurations

cy proxy.reload

Certificate file resolution

certificatesFolder  = '/etc/letsencrypt/live' or process.env.PX_CERTS_FOLDER
rootDomain          = 'example.com' in 'xyz.example.com'
cert                = certificatesFolder + '/' + rootDomain + '/' + certificateFile
key                 = certificatesFolder + '/' + rootDomain + '/' + keyFile

So xyz.example.com points to:

/etc/letsencrypt/live/example.com/fullchain.pem   for certificate
/etc/letsencrypt/live/example.com/privkey.pem     for private key

Notes

CORS handling on proxy level is convenient, but a security risk. Beware:

  • All origins are allowed, all common methods and headers, and credentials are enabled.
  • In case of an OPTIONS request, if coming via CORS (a preflight), an empty response will be send and the request ends before calling the proxied target.

Every request has additional headers:

  • x-forwarded-for: the host of the original request. If a proxy is from 'https://foo.example.com' to 'http://localhost:1234', the header will be 'foo.example.com'
  • x-forwarded-proto: 'http' or 'https', depends on the original request
  • forwarded: the standard header with the same information as the other two above