Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added HTTPS Check for Heroku #454

Closed
wants to merge 1 commit into from
Closed

Added HTTPS Check for Heroku #454

wants to merge 1 commit into from

Conversation

Nickster28
Copy link
Contributor

(Thanks to http://jaketrent.com/post/https-redirect-node-heroku/)
When hosting on Heroku, it turns out the request.secure will always be false, even if the client requests over HTTPS. Instead, Heroku adds an HTTP header 'x-forwarded-proto' specifying the protocol used ('http' or 'https'). For those on Heroku, this additional check will allow the HTTPs check to work. For those not on Heroku (where this header doesn't exist), it won't do anything.

@ghost
Copy link

ghost commented Jul 10, 2016

By analyzing the blame information on this pull request, we identified @flovilmart, @deada92 and @felipemobile to be potential reviewers.

@ghost
Copy link

ghost commented Jul 10, 2016

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

@Nickster28 Nickster28 changed the title Added https check for Heroku Added HTTPS Check for Heroku Jul 10, 2016
@drew-gross
Copy link
Contributor

This should only be done when running behind a trusted proxy, otherwise anybody could include that header and trick the dashboard into thinking it was using HTTPS. Can you change this to only trust the header if the user specifies that they want to trust it?

Also, instead of checking the header directly, you can use app.enable("trust proxy")? That does the same thing but is more robust and also takes care of the other X-Forwarded- headers.

@ghost
Copy link

ghost commented Jul 10, 2016

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@ghost ghost added the CLA Signed label Jul 10, 2016
@joeyslack
Copy link

Great fix! This resolved my issue hosting a dashboard on https on Heroku. Without it, it's impossible to host a dashboard and parse server in the same app, using the piggyback ssl cert.

@flovilmart
Copy link
Contributor

@joeyslack you should use either set('trust proxy', true) or allowInsecureHTTP but trusting X-Forwarded-Proto is bad is a general case as anyone can set that header and your server will gladly respond over HTTP.

@Nickster28
Copy link
Contributor Author

@joeyslack @drew-gross @flovilmart Take a look at my followup pull request, which addresses these issues: #535

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants