Created
September 21, 2016 07:03
-
-
Save iissnan/7c7bdc0dbcf601a44a264fe39db46a0b to your computer and use it in GitHub Desktop.
Simple Hapi Reverse Proxy
This file contains hidden or 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
const server = require('./server'); | |
server.connection({ host: '0.0.0.0', port: 80 }); | |
server.register({ | |
register: require('h2o2') | |
}).then(function (err) { | |
if (err) throw err; | |
require('./routes'); | |
server.start((err) => { | |
if (err) throw err; | |
console.log('Server running at:', server.info.uri); | |
}); | |
}); |
This file contains hidden or 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
{ | |
"name": "web-launcher", | |
"version": "1.0.0", | |
"description": "Web Launcher", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"bluebird": "^3.4.6", | |
"h2o2": "^5.1.1", | |
"hapi": "^15.0.3", | |
"lodash": "^4.16.0" | |
} | |
} |
This file contains hidden or 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
const server = require('./server'); | |
server.route({ | |
method: '*', | |
path: '/{path*}', | |
handler: { | |
proxy: { | |
host: 'example.com', | |
port: 443, | |
rejectUnauthorized: false, | |
protocol: 'https', | |
passThrough: true, | |
redirects: 5 | |
} | |
} | |
}); |
This file contains hidden or 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
const Hapi = require('hapi'); | |
const server = new Hapi.Server; | |
module.exports = server; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment