http-server icon indicating copy to clipboard operation
http-server copied to clipboard

auto HTTPS redirect

Open thisIsTheFoxe opened this issue 5 years ago • 6 comments

Please ensure that your pull request fulfills these requirements:

  • [x] The pull request is being made against the master branch
  • [ ] Tests for the changes have been added (for bug fixes / features)

What is the purpose of this pull request? (enhancement) It enables user to auto-redirects their site from HTTP -> HTTPS. To do that it listens on two ports. On one runs the (main) HTTPS server and on the other just a redirect server which takes requests and redirects them to the (main) HTTPS server.

Resolves #598 Resolves #273

What changes did you make?

  • added name to contributors
  • added --https-redirect / -R to the CLI
    • checked if -R is set and log errors if --port is wrongly configured
    • if everything checks out: make two listeners: one for http-redirect, one for the main https server
  • added a script that runs in before on the server to check whether it's a redirect server and do the redirect action

Provide some example code that this change will affect, if applicable: The only thing that effects the other parts is that I check whether -p is set and log an error if it is, but no port is passed as argument

$ node http-server -p ^^^^ this now throws an error (earlier)

Is there anything you'd like reviewers to focus on? I did a npm pretest so lint should be ok... The way I handled the actual redirect might not be prefect, but it was the only thing that worked for me .-. I hope https-redirect, redirectPort and isSSLServer are understandable ^^

Please provide testing instructions, if applicable: For testing I would need a SSL certificate, since it only works with SSL (-S -C <...>)... ¯\(ツ)/¯ I did test it tho, with a self-signed one on my machine..

thisIsTheFoxe avatar Jan 18 '20 00:01 thisIsTheFoxe

@raphaellueckl is this happening any time soon? 🙏🏼

damianobarbati avatar Mar 22 '20 15:03 damianobarbati

@damianobarbati Sorry, I am not a dev on the project. :/ I am also waiting for that feature to be shipped.

raphaellueckl avatar Jun 02 '20 20:06 raphaellueckl

any reason this PR has stalled?

WORMSS avatar Aug 16 '21 12:08 WORMSS

good question... only thing I can think of is that tests are missing, but nobody ever complained, soo..? idk 🤷‍♂️ And as explained in the PR, there's no tests for SSL/HTTPS at all (afaik), so one would have to add those before anyway (together with test-certificates)..

thisIsTheFoxe avatar Aug 19 '21 17:08 thisIsTheFoxe

Why isn't this approved yet?

Stan-Stani avatar May 11 '22 05:05 Stan-Stani

I'd love this merge, I really don't wanna learn nginx!

jonathanfishbein1 avatar Nov 09 '22 15:11 jonathanfishbein1