Socket
Socket
Sign inDemoInstall

force-ssl-heroku-eb

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    force-ssl-heroku-eb

An express middleware that redirects unencrypted HTTP requests to HTTPS


Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Install size
3.94 kB
Created
Weekly downloads
 

Readme

Source

force-ssl-heroku

An express middleware that redirects unencrypted HTTP requests to HTTPS on Heroku instances.

Heroku does SSL termination at its load balancer. However, the internal nodeJS app can tell if the original request was made with HTTP by inspecting headers inserted by Heroku. We can use this to redirect to the HTTPS Heroku url.

Installation

npm install force-ssl-heroku --save

Usage

It's designed for use with express:

var express = require('express');
var forceSsl = require('force-ssl-heroku');

var app = express();
app.use(forceSsl);

// Example:
app.get('/ping', pingHandler); // I'll now redirect to HTTPS.

// ... configure the rest of your routes.

app.listen(3000, 'localhost');

Caveat

It works because Heroku exposes your app through a reverse proxy which is used for load-balancing and other things. This reverse proxy does SSL termination and forwards to your app which should only accept connections from localhost. The middleware detects this situation by inspecting headers inserted by Heroku's reverse proxy; since headers can be spoofed, you should not use this middleware anywhere that's not behind such a proxy!

FAQs

Last updated on 25 Jan 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc