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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@gasket/plugin-https-proxy

v7.5.0

Published

Adds support for running an https proxy

Downloads

572

Readme

@gasket/plugin-https-proxy

Create an HTTPS proxy server with Gasket to use as a sidecar for frameworks that do not handle HTTPS, such as Next.js. This can be useful for local development when you want to test HTTPS features and use secure cookies for authentication, etc. It can also be used in production if it is necessary for your application to handle HTTPS requests on the container.

Installation

npm i @gasket/plugin-https-proxy

Update your gasket file plugin configuration:

// gasket.js

+ import pluginHttpsProxy from '@gasket/plugin-https-proxy';

export default makeGasket({
  plugins: [
+   pluginHttpsProxy
  ]
});

Configuration

To be set under httpsProxy in the gasket.js file.

This uses the http-proxy package and its complete set of available options.

// gasket.js
export default makeGasket({
+  httpsProxy: {
+    protocol: 'https',
+    hostname: 'my-host.com',
+    port: 443,
+    xfwd: true,
+    ws: true,
+    target: {
+      host: 'localhost',
+      port: 80
+    }
+  }
});

The above example forwards HTTPS requests on port 443 to localhost:80.

The protocol and hostname are only used for logging about the proxy server and should not be confused with target.protocol and target.host which are used for the actual destination server.

Example SNI Config

While not specifically called out in the http-proxy documentation, the ssl settings are what get passed to node's createServer method. As such, you can use SNICallback from the createServer options.

// gasket.js
export default makeGasket({
 httpsProxy: {
   protocol: 'https',
   hostname: 'my-host.com',
   port: 443,
   xfwd: true,
   ws: true,
   target: {
     host: 'localhost',
     port: 80
   },
+   ssl: {
+     SNICallback: (hostname, cb) => {
+       const ctx = tls.createSecureContext({
+         key: fs.readFileSync(`./certs/${hostname}.key`),
+         cert: fs.readFileSync(`./certs/${hostname}.crt`)
+       });
+       cb(null, ctx);
     }
   }
 }
});

The above snippet is for demonstration purposes only. You should not be reading your certs from the filesystem for each request.

Actions

startProxyServer

Use this action to start the HTTPS proxy server.

import gasket from './gasket.js';
gasket.actions.startProxyServer();

The complete flow is:

  1. Waits for gasket.isReady (ensuring async configuration is complete)
  2. Executes the prebootHttpsProxy lifecycle (one-time initialization)
  3. Executes the httpsProxy lifecycle for dynamic configuration
  4. Creates and starts the proxy server

Lifecycles

prebootHttpsProxy

This lifecycle is executed before the proxy server is started. It is a good place to execute operations that need to happen before the proxy server is started.

/**
 * Executed before the proxy server is started.
 *
 * @param {Gasket} gasket Gasket API.
 */
prebootHttpsProxy: async function prebootHttpsProxy(gasket) {
  // async operations
}

When to use prebootHttpsProxy vs prepare

The preboot lifecycle runs once when the proxy server starts, while the prepare lifecycle runs for every Gasket instance creation. Use preboot for:

  • One-time proxy server initialization
  • Setting up shared SSL/TLS contexts
  • Loading certificates that will be reused across requests
  • Establishing persistent connections or pools

Use prepare for:

  • Per-instance configuration
  • Setting up instance-specific state
  • Operations that need fresh initialization for each Gasket instance

Note: In SSR applications, new Gasket instances may be created for different contexts, causing prepare to run multiple times. For proxy servers, this can lead to unnecessary overhead. Use preboot for expensive initialization operations.

httpsProxy

While most settings can be configured in the httpsProxy configuration, this lifecycle can be used to adjust the httpsProxy options when the HTTPS proxy server is being started, which is helpful for dynamic configuration and loading of certs.

export default {
  name: 'example-plugin',
  hooks: {
    httpsProxy: async function (gasket, httpsProxyConfig) {
      return {
        ...httpsProxyConfig,
        hostname: 'local.example.com',
        port: 8443
      }
    }
  }
}

License

MIT