Here's the situation. There is PC-1 in a remote LAN network which I want to proxy my HTTP traffic from my Home PC(have public static IP). The PC(PC-1) can't listen on requests from the internet (it's behind a firewall). It(PC-1) can only initiate and connect to my Home-PC on a port. How can i use(modify) that connection to act as a proxy connection?
1st approach:
start some kind proxy program on the PC-1, I usually go with mitmproxy (mitmdump to be more precise)
# on pc1
mitmdump -p 45849
do a ssh reverse tunnel to the home pc
# on pc1
ssh -R 45849:127.0.0.1:45849 <user>@<home_pc>
configure http(s)_proxy env vars or the browser(s) to point the tunnel as socks proxy http://127.0.0.1:45849
# on home pc
export http_proxy=http://127.0.0.1:45849
export https_proxy=http://127.0.0.1:45849
2nd approach:
reverse tunnel to the home pc exposing the PC1's ssh service
# on pc1
ssh -R 45848:127.0.0.1:22 <user>@<home_pc>
use the reverse tunnel to create a 'DynamicForward' tunnel
# on home pc
ssh -p 45848 -D 45849 <user>@127.0.0.1
configure http(s)_proxy env vars or the browser(s) to point the tunnel as socks proxy http://127.0.0.1:45849
# on home pc
export http_proxy=http://127.0.0.1:45849
export https_proxy=http://127.0.0.1:45849
I use the first approach often in order to "give internet" to remote servers in secured environments, behind multiple layer of firewalls, when I have to install or update software.