8

I have an application server at work that can accept http request only from localhost.

At home I access the server through ssh. Once on the server I can curl http://localhost/test.html

I would like to do the same from my web browser at home, i.e. in some way redirect my browser traffic over ssh and access test.html as if I were on the server.

I tried ssh -v -D 9090 [email protected] and after I set a manual proxy in Firefox over a SOCKS v5 host: on ip: 127.0.0.1 and port 9090

I see something going on in ssh debugging but it looks like is not redirecting to the 80 server port

2
  • would a text-based web browser like links2 work or does it need to be a full-fledged browser?
    – sippybear
    Feb 25, 2020 at 16:41
  • You should clarify accept http request only from localhost. Do you mean the app server is bound to localhost and allows no external IP connections, or is it restricting traffic URIs via something like SNI? If it's bound to localhost, you'll have to emulate being on the box like with your SSH tunnel. If it's just restricted, such as SNI, you could put a host table entry for localhost on the remote machine and open a port on the server for the connection. Feb 25, 2020 at 22:58

1 Answer 1

8

The right syntax for create an SSH tunnel is this one:

ssh -L local_port:remote_address:remote_port [email protected]

So according to your output the command should be something similar to this:

ssh -L 9090:localhost:80 [email protected]

After establish the tunnel you don't need to configure anything on firefox just type in the URL http://localhost:9090

Hope this help

3
  • debug1: Connection to port 9090 forwarding to localhost port 80 requested. debug1: channel 3: new [direct-tcpip] channel 3: open failed: connect failed: Connection refused debug1: channel 3: free: direct-tcpip: listening port 9090 for localhost port 80, connect from 127.0.0.1 port 60758 to 127.0.0.1 port 9090, nchannels 4
    – Glasnhost
    Feb 25, 2020 at 16:51
  • if you change localhost with the IP of the server?
    – DarkVex
    Feb 25, 2020 at 16:53
  • Works perfectly. Can't say what OP is doing incorrectly.
    – Paul
    Jul 9, 2022 at 1:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .