-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c5903c9
Revert httpolyglot
jbudz 221970c
Remove httpolyglot from package.json
jbudz 165f05c
Add breaking changes docs for http redirect
jbudz dd6b6f8
Use httpolyglot in dev mode
jbudz 3a7a835
Revert "Use httpolyglot in dev mode"
jbudz 82360c4
[dev mode] Turn tls off by default
jbudz 6e415ce
Redirect from http to https
kimjoar fb8f624
No longer use 'httpolyglot' in notice text tests
kimjoar dfc0cfb
Update migration doc
kimjoar 89bf3f1
fix config setting path
kimjoar df08d01
english yo
kimjoar 9da9690
words
kimjoar f2f71d7
Handle redirect server failing to start
kimjoar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { format as formatUrl } from 'url'; | ||
import { fromNode } from 'bluebird'; | ||
import Hapi from 'hapi'; | ||
|
||
// If a redirect port is specified, we start an http server at this port and | ||
// redirect all requests to the ssl port. | ||
export default async function (kbnServer, server, config) { | ||
const isSslEnabled = config.get('server.ssl.enabled'); | ||
const portToRedirectFrom = config.get('server.ssl.redirectHttpFromPort'); | ||
|
||
// Both ssl and port to redirect from must be specified | ||
if (!isSslEnabled || portToRedirectFrom === undefined) { | ||
return; | ||
} | ||
|
||
const host = config.get('server.host'); | ||
const sslPort = config.get('server.port'); | ||
|
||
if (portToRedirectFrom === sslPort) { | ||
throw new Error( | ||
'Kibana does not accept http traffic to `server.port` when ssl is ' + | ||
'enabled (only https is allowed), so `server.ssl.redirectHttpFromPort` ' + | ||
`cannot be configured to the same value. Both are [${sslPort}].` | ||
); | ||
} | ||
|
||
const redirectServer = new Hapi.Server(); | ||
|
||
redirectServer.connection({ | ||
host, | ||
port: portToRedirectFrom | ||
}); | ||
|
||
redirectServer.ext('onRequest', (req, reply) => { | ||
reply.redirect(formatUrl({ | ||
protocol: 'https', | ||
hostname: host, | ||
port: sslPort, | ||
pathname: req.url.pathname, | ||
search: req.url.search, | ||
})); | ||
}); | ||
|
||
try { | ||
await fromNode(cb => redirectServer.start(cb)); | ||
} catch (err) { | ||
if (err.code === 'EADDRINUSE') { | ||
throw new Error( | ||
'The redirect server failed to start up because port ' + | ||
`${portToRedirectFrom} is already in use. Ensure the port specified ` + | ||
'in `server.ssl.redirectHttpFromPort` is available.' | ||
); | ||
} else { | ||
throw err; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah