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

Revert same port http -> https redirect #10930

Merged
merged 13 commits into from
Jul 7, 2017

Conversation

jbudz
Copy link
Member

@jbudz jbudz commented Mar 29, 2017

  • httpolyglot is removed, we no longer automatically redirect from http to https
  • server.ssl.redirectHttpFromPort option added to allow for http -> https redirect from one port to another
  • We no longer start the dev server with tls by default, it can be turned on with the --ssl flag, npm start -- --ssl, or ./bin/kibana --dev --ssl
  • There will be error log messages if you connect over the wrong protocol, we have [logging] Downgrade hapi connection errors when connecting with the w… #11209 for downgrading these

Closes #10181

Release Note: Kibana 5.x redirected requests from http to https on the same port if TLS was configured. Starting in Kibana 6.0.0 Kibana no longer redirects basic http traffic to https.

@epixa
Copy link
Contributor

epixa commented Mar 29, 2017

I got to thinking about this recently. I think there may still be value in http->https redirection, I just think the current approach was too heavy handed. Doing this on a single port is kind of nuts, but if they are binding to port 443 for SSL, it certainly would be convenient to also bind to port 80 purely for the sake of redirection. This would be the obvious use case for most people, I think.

Anyone thoughts?

Edit: This wouldn't require third party dependencies.

@tylersmalley
Copy link
Contributor

@epixa to accomplish that wouldn't we need to expose an additional port and provide configuration for it?

@jbudz
Copy link
Member Author

jbudz commented Mar 29, 2017

I'll make an update, something like server.ssl.redirectPort.

@tylersmalley
Copy link
Contributor

Thoughts on server.httpPort and server.httpsPort? server.port could set both of the values to provide backwards compatibility. To allow for redirection httpPort and httpsPort would have to differ.

@epixa
Copy link
Contributor

epixa commented Mar 29, 2017

Would it need any other configurations? The use case is you pointing hostname to Kibana, and running Kibana with ssl.enabled. In that case, can we not just assume port 80 with all the same relevant configurations from the main Kibana config (e.g. basePath, etc)? I don't see why we would need to make this port configurable.

I could imagine someone wanting to disable this functionality, though.

@tylersmalley
Copy link
Contributor

tylersmalley commented Mar 29, 2017

Using port 80 would require privileged permissions to start Kibana. It's possible, but it would be a large change from what we have now. In addition, we would be more prone to port conflicts.

@epixa
Copy link
Contributor

epixa commented Mar 29, 2017

@tylersmalley As would 443 (or any other port that doesn't show up in URLs), so that should be fine. In other words, someone should only be able to trigger this behavior if they are already using privileged permissions.

If someone configures Kibana to use SSL on port 5601, for example, then there's no need to do extra redirects.

The idea here is that if people are exposing Kibana directly to the web, we'll handle https redirects from port 80 to ensure their browser redirects to https. But if they put Kibana behind a reverse proxy, they should handle the https redirect on their own.

@tylersmalley
Copy link
Contributor

@epixa, I believe we are on the same page but I might have been miss-directed by your previous comment about not requiring additional configuration beyond hostname and ssl.enabled. With this, we will still need the ability to configure the http/https ports. If we default to any port under 1024 we will most definitely need a way for them to change the ports and not require root to run.

@tylersmalley
Copy link
Contributor

Let's decouple the redirect discussion from the PR and leave it as-is. I will create a new issue documenting the solutions brought up thus far.

Copy link
Contributor

@tylersmalley tylersmalley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM - I have created a new issue to track the discussion on how to handle the redirection.

@tylersmalley
Copy link
Contributor

Here is that issue: #10948

@ycombinator ycombinator self-requested a review March 31, 2017 18:06
Copy link
Contributor

@ycombinator ycombinator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. This seems like a breaking change - links to http://... would now no longer automagically work. Should this be documented somewhere?

Copy link
Contributor

@ycombinator ycombinator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spoke too soon with the LGTM :)

Besides documenting the breaking change, there's another thing I just noticed running this PR:

If I make a request to http://localhost:5601, I see errors like this in the Kibana server log:

server    log   [18:32:52.755] [error][client][connection] Error: 140736487396288:error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request:../deps/openssl/openssl/ssl/s23_srvr.c:394:

    at Error (native)

@ycombinator
Copy link
Contributor

ycombinator commented Mar 31, 2017

Per out-of-band conversation with @jbudz, the server log error I mentioned in the previous comment will be addressed via #10929.

If we merge this PR, the server log error will be reported a lot more frequently so I think we should try to resolve 10929 before this PR can be merged.

@spalger
Copy link
Contributor

spalger commented Apr 1, 2017

For the record, I really don't like the way this feels in development

@epixa
Copy link
Contributor

epixa commented Apr 3, 2017

@spalger Perhaps this is something we could bake into the basePath proxy (and rename it to dev proxy or something).

@spalger
Copy link
Contributor

spalger commented Apr 3, 2017

@jbudz what do you think about keeping this for dev? I'm 100% for it

@jbudz
Copy link
Member Author

jbudz commented Apr 3, 2017

Leaving it in dev mode minimizes any concerns I had with it, so I'm up for it. We already have the base path proxy which we of course aren't shipping either.

It was frustrating me while writing this PR, but I figured once my browser autocomplete fixed on the right protocol it would be fine.

@jbudz
Copy link
Member Author

jbudz commented Apr 3, 2017

Is anyone against this in dev mode only?

@spalger
Copy link
Contributor

spalger commented Apr 3, 2017

I've been using it for a couple days and keep feeling dislike :/

@tylersmalley
Copy link
Contributor

I am fine keeping it only for development. We can always review down the road, but this at least removes it from builds for now.

Copy link
Contributor

@epixa epixa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more I think about it, the more important the port 80 redirection seems to be, and I don't think we should move forward with this change without it in the same PR. The comment that I left on the breaking change is just one example of the strangeness this will have if we went forward as-is. And the error messages thing when accessed using the wrong protocol is probably worth blocking the release on, so merging this PR effectively puts the release in limbo until we address the other thing.

I actually think the error message itself is fine so long as the port redirection feature is available, though it would be awesome if we could provide a more useful error message that points people to this configuration.

=== Removed same port http to https redirect behavior
*Details:* Kibana 5.x redirected requests from http to https on the same port if TLS was configured. This was removed.

*Impact:* You may need to add a redirect on a different port if a redirect is expected.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know the plan here is to follow up with a different PR to handle port redirection stuff, but when this specific PR is merged, the reality is going to be that there is no way to do http -> https redirection in Kibana. We should update the breaking changes impact to mention that the only way to accomplish this would be to custom handle http -> https redirection in a reverse proxy or at the load balancer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The follow up PR that handles http -> https support will need to then modify this breaking change documentation, obviously.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My overall review comment makes this feedback moot, but I'm leaving it here for posterity's sake.


[float]
=== Removed same port http to https redirect behavior
*Details:* Kibana 5.x redirected requests from http to https on the same port if TLS was configured. This was removed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than "This was removed", let's err on the side of more information even if it seems a bit redundant. Perhaps "Kibana 5.x redirected requests from http to https on the same port if TLS was configured. Starting in Kibana 6.0.0, Kibana no longer redirects basic http traffic to https."

@kimjoar
Copy link
Contributor

kimjoar commented Jul 6, 2017

I pushed a suggestion for redirecting http to https here. @epixa can you take a look?

@@ -9,11 +9,11 @@ const NODE_MODULES = resolve(__dirname, '../../../../node_modules');
const NODE_DIR = resolve(process.execPath, '../..');
const PACKAGES = [
{
name: '@elastic/httpolyglot',
version: '0.1.2-elasticpatch1',
name: '@spalger/filesaver',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's switch this to being a controlled package that we know will always exist because we've created it specifically for this purpose. We can create an npm package under the @elastic org that does nothing except provide the license we want to verify against, and then we can depend on that package in our devDependencies. We should never need to update this test just because we decided to no longer depend on a given package in our source.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okey if I do it in a separate PR? (Just want to make sure this gets ready for 6.0)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah

import { format as formatUrl } from 'url';
import Hapi from 'hapi';

// If a redirect port is specified, we need to start a server a non-ssl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to start a server a non-ssl server at this doesn't english good.

const host = config.get('server.host');
const sslPort = config.get('server.port');

const redirectServer = new Hapi.Server();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't block on this, but I really wish we just used a native node http server for this. I have much greater confidence in that abstraction in general than I do in hapi, both in terms of how lightweight it is, and how stable the API is.

This works though.

Copy link
Contributor

@epixa epixa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we provide a more useful error message before exiting when the redirect port is the same as the main port? Right now it just does a generic error:

server    log   [13:11:39.894] [fatal] Port 5601 is already in use. Another instance of Kibana may be running!
FATAL Port 5601 is already in use. Another instance of Kibana may be running!

But ideally we'd instead say something specific to let the user know that ssl.server.redirectHttpFromPort cannot be set to the same port as server.port, or something like that.

@epixa
Copy link
Contributor

epixa commented Jul 7, 2017

LGTM other than the generic error message

@epixa epixa dismissed ycombinator’s stale review July 7, 2017 13:21

We're going to tackle the downgrading alongside this PR, so this feedback should be addressed with that.

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

Successfully merging this pull request may close these issues.

7 participants