July 20, 2020

Browse web application from remote server to local client

So lets say you have a case where you do development of a hugo web site on a remote server and when running the preview hugo server -D -p 1313 on the remote server you want to verify the web content on your local client machine by browsing http://localhost:1313 e.g

    Note left of Client: http://localhost:1313
    Client->>Remote: ssh -L 1313:localhost:1313 user@server
    Note right of Remote: Hugo port 1313 
    Remote-->Client: connection started

This is possible by doing a local ssh forwarding

So the basic command looks something like this:

ssh -L 1313:localhost:1313 user@server

Lets brake the above command down:

  1. -L will make a local forwarding
  2. The first 1313: is the port on your local client that should be forwarded. E.g if you browse to http://localhost:1313 all traffic on 1313 will be forwarded to the remote server
  3. The second part localhost:1313 is where the traffic from the local client will be forwarded on the remote server. In this case we are using localhost:1313 on the remote server, so it will redirect all local client traffic to it’s own localhost:1313
  4. user@server is the server you want to local forward to.

Some configurations to verify as ssh configurations might differ on your remote machines:


ssh local forwarding is awesome when you are working on a remote machine that does not have public access and you want to verify some changes to the internal web server running there. Another great thing is that you can use this approach to develop web pages with a lightweight client such as chromebook.

comments powered by Disqus

© Anis Alekic 2020