Skip to content

map HTTPS server variable to x-forwarded-proto header #265

@jfromaniello

Description

@jfromaniello

I wonder if you could map the https server variable ON/OFF to the x-forwarded-proto header HTTP/HTTPS.

I guess this is the best because all examples run a node http server, so I see iisnode somehow as a reverse proxy.

Right now I am promoting the server variable in the web.config and then doing something like this:

var protocol;

//this works when the incoming message is run by an https node server.
if(req.connection.encrypted) {
  protocol = 'https';
  return;
}

if(req.headers['x-iisnode-https'] && req.headers['x-iisnode-https'] == 'ON') {
  protocol = 'https';
  return;
}

// x-forwarded-proto is sent when running on heroku, nodejitsu, or using nginx reverse proxy.
protocol = req.headers['x-forwarded-proto'] || 'http';

@gissues:{"order":50,"status":"inprogress"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions