-
-
Save mralexgray/6ec450f4bca2043f3f88d8c0385e49df to your computer and use it in GitHub Desktop.
node-http-proxy routing proxy with websockets
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
httpProxy = require 'http-proxy' | |
proxy = httpProxy.createProxy ws:true | |
options = | |
'herp.dev': 'http://0.0.0.0:9008' | |
'derp.dev': 'http://0.0.0.0:3000' | |
server = require('http').createServer (req, res) -> | |
proxy.web req, res, { target: options[req.headers.host] }, (e) -> | |
log_error e, req | |
log_error = (e, req) -> return if not e | |
console.error e.message | |
console.log "#{req.headers.host} --> #{options[req.headers.host]}\n-----" | |
server.on 'upgrade', (req, res) -> | |
proxy.ws req, res, { target: options[req.headers.host] }, (e) -> | |
log_error e, req | |
server.listen 80 |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2004 Sam Hocevar <[email protected]> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
0. You just DO WHAT THE FUCK YOU WANT TO. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment