Skip to content

Instantly share code, notes, and snippets.

@iissnan
Created September 21, 2016 07:03
Show Gist options
  • Save iissnan/7c7bdc0dbcf601a44a264fe39db46a0b to your computer and use it in GitHub Desktop.
Save iissnan/7c7bdc0dbcf601a44a264fe39db46a0b to your computer and use it in GitHub Desktop.
Simple Hapi Reverse Proxy
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);
});
});
{
"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"
}
}
const server = require('./server');
server.route({
method: '*',
path: '/{path*}',
handler: {
proxy: {
host: 'example.com',
port: 443,
rejectUnauthorized: false,
protocol: 'https',
passThrough: true,
redirects: 5
}
}
});
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