-
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
Changes from 10 commits
c5903c9
221970c
165f05c
dd6b6f8
3a7a835
82360c4
6e415ce
fb8f624
dfc0cfb
89bf3f1
df08d01
9da9690
f2f71d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
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 | ||
// server at this port, and redirect all requests to the ssl port. | ||
export default 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'); | ||
|
||
const redirectServer = new Hapi.Server(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
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, | ||
})); | ||
}); | ||
|
||
redirectServer.start((err) => { | ||
if (err) { | ||
throw err; | ||
} | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Yeah |
||
version: '1.1.2', | ||
licenses: ['MIT'], | ||
directory: resolve(NODE_MODULES, '@elastic/httpolyglot'), | ||
relative: 'node_modules/@elastic/httpolyglot', | ||
directory: resolve(NODE_MODULES, '@spalger/filesaver'), | ||
relative: 'node_modules/@spalger/filesaver', | ||
}, | ||
{ | ||
name: 'aws-sdk', | ||
|
@@ -41,7 +41,7 @@ describe('tasks/lib/notice', () => { | |
}); | ||
|
||
it('includes *LICENSE* files from packages', () => { | ||
expect(notice).to.contain(readFileSync(resolve(NODE_MODULES, '@elastic/httpolyglot/LICENSE'), 'utf8')); | ||
expect(notice).to.contain(readFileSync(resolve(NODE_MODULES, '@spalger/filesaver/LICENSE.md'), 'utf8')); | ||
}); | ||
|
||
it('includes the LICENSE file from node', () => { | ||
|
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.
we need to start a server a non-ssl server at this
doesn't english good.