virtkick/http-master

Redirect from http to https

Opened this issue · 4 comments

Hi,
I am trying to redirect a subdomain from http to https very similar to the example given in readme.

80: {
  router: {
    "sub.atlashost.eu": "https://sub.atlashost.eu/[path]",
    "*": 8080
  }
}, 
443: {
  router: {
    "sub.atlashost.eu":    4500
  },
  ssl: {
    letsencrypt: true,
    spdy: true
  }  
}    

this is working for any path, but root is NOT redirected and I am getting 404 Not Found instead.

As I only need a redirect to the root I tried (with and without trailing "/" )

"sub.atlashost.eu": "https://sub.atlashost.eu",

but now there is NO redirect and http - request are just going through ... to port 4500 although it is not mentioned in the upper section!!

I am doing sudo systemctl restart http-master after each change and restarting my express app does not help either. I even did reboot my entire server. I tried to disable spdy as well.

Some more testing revealed, that [path] seems just not working at all ... I think it was chrome which redirected me to https if not root. If explicitly started with http:// I get 404 Not Found again.

And it seems that without [path] I am forwarded instead of redirected ...

Uh ... finally I found the redirect -> syntax. Everything is working now!

I guess without redirect -> it is just forwarding? If so I'd like to improve documentation on this point...

Rush commented

I guess without redirect -> it is just forwarding? If so I'd like to improve documentation on this point...

That's right! Initials versions of http-master had a separate forwarding/routing mapping but at one point I decided there should be only one mapping table per port with forwarding/routing as the default behavior and other behaviors as modules invoked with moduleName -> target - in this case "redirect -> https://something`.

I would appreciate any PR for documentation you deem necessary to make it better.

If you think that redirect could be achieved in a simpler way please let me know too.

Rush commented

but now there is NO redirect and http - request are just going through ... to port 4500 although it is not mentioned in the upper section!!

This is quite funny :) You set up forwarding from sub.atlashost.eu:80 to sub.atlashost.eu:443 and then to localhost:4500. I never considered such usage.