
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
https-redirect-server
Advanced tools
A node module to redirect requests from a non-secure port to a secure port.
A node module to redirect requests from a non-secure port to a secure port.
This is a node module that currently supports two ways of redirecting from a non-secure connection to a secure connection.
If you want to force all traffic to come to your site via a secure connection, a small, lightweight http server can be run to redirect all traffic to https and a secure port.
If you want to force specific routes to use a secure connection, a middleware function can be used with express to redirect insecure traffic to https and a secure port.
This will start a server running on an insecure port that will redirect all traffic. Here is an example of how to use it alongside an express server:
var express = require('express');
var https = require('https');
var port = process.env.PORT || 8080;
var securePort = process.env.PORT || 8443;
var httpsRedirect = require('https-redirect-server');
// configure application and routes
app.get('/', function(req, res, next) {
// ...
});
app.get('/login', function(req, res, next) {
// ...
});
// set ssl options
var ssl_options = {
key: fs.readFileSync(__dirname + '/website.key'),
cert: fs.readFileSync(__dirname + '/website.cert')
};
// start servers
httpsRedirect(port, securePort).server(); // will redirect anything to receives
https.createServer(ssl_options, app).listen(securePort);
This will only redirect routes that you specify to use the middleware. Here is an example of how to redirect traffic that is going to the login page of an express server:
var express = require('express');
var http = require('http');
var https = require('https');
var port = process.env.PORT || 8080;
var securePort = process.env.PORT || 8443;
var httpsRedirect = require('https-redirect-server');
var forceSecure = httpsRedirect(port, securePort);
// configure application and routes
app.get('/', function(req, res, next) {
// ...
});
// add middleware to redirect request if it is not secure
app.get('/login', forceSecure, function(req, res, next) {
// ...
});
// set ssl options
var ssl_options = {
key: fs.readFileSync(__dirname + '/website.key'),
cert: fs.readFileSync(__dirname + '/website.cert')
};
// start servers, one for insecure and one for secure
http.createServer(app).listen(port);
https.createServer(ssl_options, app).listen(securePort);
FAQs
A node module to redirect requests from a non-secure port to a secure port.
We found that https-redirect-server demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.