1

enter image description here

I'm trying to make a HTTP/S proxy server work without having to manually port forward.

  • Machine A has installed a proxy server
  • Machine A is behind a NAT (or a router with firewall).
  • Machine B tries to browse internet through Machine A proxy.
  • Machine B isn't behind a NAT.
  • Both machines know each other before any connection is made.
  • In a full scale, there would be multiple Machine A but only one Machine B.

Machine A shouldn't need to configure anything on the router.

I have thought about using uPnP, as per this answer, but as the title of this question, I wanted to know if it would be possible to invert the roles of the machines.

Instead of Machine B initiating a connection, Machine A will do it. So Machine A would be the client and Machine B would be the server. Remember Machine A knows the IP address of Machine B beforehand.

In this scenario, Machine A would still function as a proxy, but having the role of the client in a standard TCP connection.

I understand this would need a custom-made proxy server, which is no problem since the proxy server is implemented in python and I have access to the source, and can modify it.

  • Will this be compatible with normal HTTP/S proxy? Specifically I will be using python requests on Machine B.
  • Does this method have a name? Researching for inverse or reverse lands me on reverse proxy which AFAIK doesn't have anything to do with what I'm trying to accomplish.
  • Is there something I'm missing? Or an alternative solution? (besides uPnP)
ewwink
  • 18,382
  • 2
  • 44
  • 54
Jorjon
  • 5,316
  • 1
  • 41
  • 58

2 Answers2

1

a simple solution is OpenSSH port forwarding.

first forward port 20000 on "Machine B" to port 10000 on "Machine A" with remote port forwarding:

[A]$ ssh -N -R 20000:localhost:10000 Machine_B

then setup a tunnel on port 10000 on "Machine A" with dynamic port forwarding:

[A]$ ssh -N -D 10000 localhost

now you can use 127.0.0.1:20000 as a SOCKS5 proxy on "Machine B":

[B]$ curl --socks5 127.0.0.1:20000 example.com
georgexsh
  • 15,984
  • 2
  • 37
  • 62
0

it called "Reverse", you need shootback to reverse TCP tunnel, it work like OpenSSH port forwarding and Socks5 proxy server like pysocks it better than HTTP/S proxy server.

on MachineB (You)

python3 master.py -m 0.0.0.0:10000 -c 0.0.0.0:10800

on MachineA (Remote)

python socks5.py start --port=1080
python slaver.py -m <MachineA_IP>:10000 -t 127.0.0.1:1080

now on MachineB you can set browser or any app to socks5

localhost:10800
ewwink
  • 18,382
  • 2
  • 44
  • 54