Created
February 7, 2025 05:39
-
-
Save llseek/c2669a3851764c05d45d285255602cbc to your computer and use it in GitHub Desktop.
ssh reverse proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
假设有三台机器,网络连接为:外网 <- A <-> B <-> C | |
假设A的1081端口上运行着一个http代理,想让C通过这个代理访问外网,步骤如下: | |
1. 在B上设置端口转发,本地端口12345端口收到的请求转发到A的1081端口(需要保持ssh一直运行着) | |
ssh -v -N -L 12345:ipA:1081 userA@ipA | |
2. 在B上设置反向隧道,C的23456端口收到的请求转发到B的12345端口(需要保持ssh一直运行着) | |
ssh -v -N -R 23456:localhost:12345 userC@ipC | |
3. 在C上设置http_proxy/https_proxy环境变量后即可访问外网 | |
export http_proxy=http://localhost:23456 | |
export https_proxy=http://localhost:23456 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment