Skip to content

Instantly share code, notes, and snippets.

@euoia
Last active December 15, 2015 02:59
Show Gist options
  • Save euoia/5190711 to your computer and use it in GitHub Desktop.
Save euoia/5190711 to your computer and use it in GitHub Desktop.
var http = require('http');
var httpProxy = require('http-proxy');
var proxyOptions = {
pathnameOnly: true,
router: {
'/app': 'localhost:3000',
'/accounts': 'localhost:8001'
}
}
httpProxy.createServer(
proxyOptions,
function (req, res, next) {
console.log('incoming');
next();
}
).listen(3001);
@euoia
Copy link
Author

euoia commented Mar 18, 2013

Here's what I see with netcat when a request comes in from the web browser:

~|⇒ nc -l 8001
GET / HTTP/1.1
host: localhost:3001
connection: keep-alive
accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22
accept-encoding: gzip,deflate,sdch
accept-language: en-GB,en;q=0.8,en-US;q=0.6
accept-charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
cookie: connect.sid=s%3Ag2fuSh4Pph4DJ8GfMK6AcdaN.YuA1sA2N0PT5lvDn4QSwjvKrKLLetzpGaumrBAZn3NY
x-forwarded-for: 127.0.0.1
x-forwarded-port: 55932
x-forwarded-proto: http

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment