问题
I have a webapp running on a Raspberry Pi, which is behind a NAT, and I'm trying to make a tunnel to the company's server so that I can access it from the web. Right now I've been able to establish a tunnel using ssh -fN -R 192.168.0.28:54321:localhost:443 username@192.168.0.28
(both the server and the RPi are in the same LAN at the time), and doing curl -k https://192.168.0.28:54321
returns the contents of the webpage hosted in the RPi, but only if I do it from the server. I have set GatewayPorts yes
and AllowTcpForwarding yes
(which anyway is the default).
回答1:
It was the firewall on the server blocking the port. ¬¬
To open said port, the command is sudo iptables -I INPUT -p tcp --dport 54321 -j ACCEPT
, which says that any connection comming to the TCP port 54321 must be accepted.
来源:https://stackoverflow.com/questions/43879303/ssh-reverse-tunnel-not-working-for-webserver