开发者

run web app through SSH

开发者 https://www.devze.com 2023-04-03 06:31 出处:网络
I have a VMWare virtual Linux server on which i installed a Java EE web application. i access the server via SSH.

I have a VMWare virtual Linux server on which i installed a Java EE web application. i access the server via SSH.

my question is how can i run the remote web app through ssh?

what i did is start remote tomcat server over ssh then in my browser i invoked this address :

 http://<ssh-server-host&g开发者_运维问答t;:8080

the connection took very long and my firefox can't establish connection b/c it takes too long.

is there a clean way to run a web app over ssh?


What you are doing can also be called ssh tunneling. It has the advantage that your traffic will be encrypted, but it will also be a bit slower (encryption/decryption being done by ssh), and more resource intensive. Besides, the tunnel will have to stay open in order to access the endpoint.

The technique is specially useful if you are not interested in making a service remotely accessible, but still want to use privately.

For example, I have a couchdb server listening on localhost:5984, in my host "server1" I can make that port locally accessible in port 22222 in my desktop computer, by doing:

desktop $ ssh -f user@server1 -L localhost:22222:server1:5984 -N

This way I can access my remote couchdb:

curl -X GET http://localhost:22222

And that even though the remote couchdb server is only listening to local connections. The SSH tunnel makes the magic.


using a technique called ssh port forwarding i did the following:

$ssh -N -f -L 8080:localhost:8080 user@ssh-server-host 

The connection is forwarded to port 8080 on the remote server. i open a web browser and type the url http://localhost:8080/webapp

it seems this works!

any comments about this method?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号