Skip to content

Instantly share code, notes, and snippets.

@MouseZero
Last active May 3, 2019 06:08
Show Gist options
  • Save MouseZero/20c5fc1211d6379bc8787c620807691e to your computer and use it in GitHub Desktop.
Save MouseZero/20c5fc1211d6379bc8787c620807691e to your computer and use it in GitHub Desktop.
http-proxy-server
var app, server,
proxy = require('express-http-proxy')
express = require('express'),
path = require('path'),
host = process.env.HOST || '127.0.0.1',
port = process.env.PORT || 3333,
root = path.resolve(__dirname, './src');
app = express();
app.use(function(req, res, next) { console.log(req.url); next(); });
app.use(express.static(root + '/'));
app.use('/', proxy('www.google.com'));
server = app.listen(port, host, serverStarted);
function serverStarted () {
console.log('Server started', host, port);
console.log('Root directory', root);
console.log('Press Ctrl+C to exit...\n');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment