Created
June 7, 2013 09:01
-
-
Save vol4ok/5727997 to your computer and use it in GitHub Desktop.
share local server to remote server via ssh
This file contains 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
LOCAL_PORT = 3333 | |
REMOTE_PORT = 2222 | |
SSH_USER_HOST = "[email protected]" | |
express = require "express" | |
{spawn} = require "child_process" | |
ssh = spawn('ssh', ['-N', '-R', "#{REMOTE_PORT}:localhost:#{LOCAL_PORT}", SSH_USER_HOST]) | |
app = express() | |
.use(express.favicon()) | |
.use(express.bodyParser()) | |
.use(express.logger("short")) | |
app.get "/", (req, res) -> | |
res.send("Hello world! I'm a local webserver! Woooooo!") | |
app.get "/exit", (req, res) -> | |
res.send("BYE!") | |
ssh.kill() | |
srv.close() | |
srv = app.listen(LOCAL_PORT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
add
GatewayPorts yes
to your sshd_config to allow binding to remote sockets