Created
February 9, 2012 21:44
-
-
Save indexzero/1783490 to your computer and use it in GitHub Desktop.
A simple outbound proxy server with node-http-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
| var httpProxy = require('http-proxy'); | |
| var server = httpProxy.createServer(function (req, res, proxy) { | |
| // | |
| // Inspect the request | |
| // | |
| console.dir(req); | |
| // | |
| // Proxy to the Remote Location | |
| // | |
| proxy.proxyRequest(req, res, { | |
| host: 'path-to-remote-api-endpoint.com', | |
| port: 80 | |
| }); | |
| }); | |
| // | |
| // Start the proxy server. You should connect to | |
| // http://localhost:3000/ | |
| // | |
| server.listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment