Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Using Putty, I have set up a reverse proxy which allows me to connect on port 8080 of the server at server.tld to port 80 of the machine which initiated the SSH connection.

The server allows me to connect on localhost:8080 and returns the result of initiator:80 when I connect on the server.

This question says to enable GatewayPorts and bind to all addresses.

Using Putty, how can I expose port 8080 on the server so that when a request comes through on the external interface (e.g. a web request) the port is forwarded to the initiator:80?

enter image description here

share|improve this question
    
Can you detail exactly what you're putting into the PuTTY dialog to create the tunnel? –  EightBitTony May 10 '12 at 13:55
    
Added a screenshot - ports are different than the example text, however this is not allowing a request on the external interface to route through the tunnel (e.g. 1.2.3.4:8080). Internal requests are routed (localhost:8080). –  Darbio May 11 '12 at 4:51
    
What does netstat -an | grep 8080 show? And when you say not allowing, what do you mean? Do you have a firewall blocking connections to port 8080? –  EightBitTony May 11 '12 at 6:47

1 Answer 1

There are two checkboxes when setting up the PuTTY tunnel,

  • Local ports accept connections from other hosts
  • Remote ports do the same (SSH-2 only)

the second of those does what you need.

I just tested it,

PuTTY tunnels dialog,

  • Tick Remote ports ...
  • Put 8080 into Source port
  • Put 127.0.0.1:80 into Destination port
  • Select 'Remote' radio button
  • Click Add
  • Connect

Works fine, here's the resulting netstat,

# netstat -an | grep 8080
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN
tcp6       0      0 :::8080                 :::*                    LISTEN

You can also use plink.exe that comes with PuTTY, for example,

plink -R *:8080:localhost:80 user@remote.host.example

which works fine as well.

# netstat -an | grep 8080
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN
tcp6       0      0 :::8080                 :::*                    LISTEN

If you're still getting 127.0.0.1:8080 on the host, then GatewayPorts is still set to no in your sshd config.

Also, don't forget to update the firewall on the target server to allow external connections to port 8080.

share|improve this answer
    
No - it doesn't seem to give me the same behaviour as ssh -R *:8080:localhost:80 should it? –  Darbio May 10 '12 at 12:35
    
GatewayPorts is set to yes. It works with the ssh -R \*:8080:localhost:80 command, just couldn;t figure it out in PuTTy –  Darbio May 11 '12 at 4:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.