Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6162945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:44:32+00:00 2026-05-23T21:44:32+00:00

Based on the response to this question: How do I configure nodejs/expressjs to serve

  • 0

Based on the response to this question:

How do I configure nodejs/expressjs to serve pages over https?

I’ve been trying to set up the equivalent of:

var express = require('express');
var fs = require("fs");
var crypto = require('crypto');

var app = express.createServer();
var appSecure = express.createServer();
var privateKey = fs.readFileSync('privatekey.pem').toString();
var certificate = fs.readFileSync('certificate.pem').toString();
var credentials = crypto.createCredentials({key: privateKey, cert: certificate});
appSecure.setSecure(credentials);


app.get('/secretStuff', function(req,res) {
//redirect to https
}

appSecure.get('/secretStuff', function(req, res) {
//show you the secret stuff
}

Is this something that’s doable with the current release of expressjs and node 2.4?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:44:32+00:00Added an answer on May 23, 2026 at 9:44 pm

    Yes, this can be done and it looks like you already have most of what you need. Just send the redirect in your app.get handler

    app.get('/secretStuff', function(req,res) {
      res.redirect('https://' + req.header('Host') + req.url);
    }
    

    Also make sure you do something like app.listen(80) and appSecure.listen(443) to actually start the servers on the appropriate port. Otherwise be sure to construct the HTTPS URL with the correct port. For production, this thing is typically handled outside of your app server (node.js) with a reverse proxy like nginx. It is trivial to do this in nginx which will let your node.js process run as non-root and remove the need to have clients directly connecting to node.js, which is not as battle-hardened as nginx for serving live internect TCP connections (I’m paraphrasing Ryan Dahl himself here).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Based on the response to this question: Why does C++ have header files and
Based in part on the advice in this response to a question on SO
Thanks for taking time to review this question. I've been trying to fix a
Based on this question it appears that the default template for CheckStyle will allow
I'm new to prototype-based languages and have read this question: Preserving a reference to
This question flows from the answer to: How does one set up multiple accounts
This is a broad-based question around delivering a javascript library that other web developers
My question is basically this: If I set dynamic data from one class, can
I've read every response I could fine on SO before posting this question. Although
Clarification: this question was about GZIPping an JAX-WS-based REST service, but I've decided to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.