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

Can't seem to enforce HTTPS #10

Closed
rastenis opened this issue Jul 18, 2017 · 10 comments
Closed

Can't seem to enforce HTTPS #10

rastenis opened this issue Jul 18, 2017 · 10 comments

Comments

@rastenis
Copy link

If i set up the target to be "target": "http://localhost:10202", and set "enable", "generate" and "secureOnly" to true, i can:

  1. Access it without HTTPS by just going to the address i registered in routerTable
  2. Access it with HTTPS by prepending https:// to the address i registered in routerTable

and if i redirect insecure connections to https:// from the application itself, it gets redirected back to http:// indefinitely(until the browser drops out).

Am i missing something here?

@Irrelon
Copy link
Owner

Irrelon commented Jul 19, 2017

Hey ya. That definitely doesn't seem right. When you say you can access the address via http, do you mean the source address (external facing) or internal address (only accessible inside your network)?

@rastenis
Copy link
Author

Thanks for the reply,

I access my servers via registered domains. Haven't tried LAN IPs yet.

@rastenis
Copy link
Author

rastenis commented Aug 1, 2017

Yeah, i completely removed the http listener, so it becomes impossible to connect via insecure means. The router, however, accepts the connection and proceeds to relay the connection to the server via https.

*the client keeps operating in http, though (if accessed through http://domain.something). A secure connection is only established if the client connects through https://domain.something .

 "routerTable": {
        "domain.something": {
            "target": "https://localhost:10200",
            "ssl": {
                "enable": true,
                "generate": true,
                "secureOnly": true
            },
            "errorRedirect": "https://www.google.com"
        }
    }

@rastenis
Copy link
Author

rastenis commented Aug 2, 2017

The issue seems to stem from if (route.ssl && route.ssl.onlySecure) , as route.ssl.onlySecure always seems to be undefined, and so the http prevention never kicks in.

I ended up bodging in https re-routing by removing the http server's ability to call handleRequest , and making it so it 301's the client back to "https://" + req.headers.host + "/" , which in turn establishes a secure connection.

@Irrelon
Copy link
Owner

Irrelon commented Aug 2, 2017

If the code is if (route.ssl && route.ssl.onlySecure) but you are using the flag in the config as secureOnly then it will not work - did I put the incorrect name in the config example?

@Irrelon
Copy link
Owner

Irrelon commented Aug 2, 2017

So it appears that this is my fault, putting the incorrect config field name in the examples!

@Irrelon
Copy link
Owner

Irrelon commented Aug 2, 2017

Are you able to try it with the correct name "onlySecure"?

@rastenis
Copy link
Author

rastenis commented Aug 2, 2017

I completely missed that. A re-route option would be great for people that don't want their clients to get 404s if they don't specifically type in https://.

Thanks.

@rastenis rastenis closed this as completed Aug 2, 2017
@Irrelon
Copy link
Owner

Irrelon commented Aug 4, 2017

@Scharkee Agreed on the reroute! If you get a chance it would be great to have a pull request with that feature. Me = swamped at the moment :(

@Irrelon
Copy link
Owner

Irrelon commented Aug 29, 2017

@Scharkee Auto-redirecting insecure connections is now done. You have to specify it manually in each ssl section as "insecureRedirect". It can either be a boolean or a string. If set to true, will take the host name and prepend "https://" to it and redirect user there. If a string, will simply redirect user to whatever that string is. Uses 302 redirect so it is not permanent.

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

No branches or pull requests

2 participants