nickshanks

joined 1 year ago
[–] nickshanks 1 points 1 year ago

I realised I forgot to update this. Thank you to everyone that contributed, I appreciate it. This was a weird use case and barely anyone online has documented it, only a handful of places. Nevertheless, I figured it out.

So basically, you run HAProxy with the send-proxy-v2 protocol. Let’s say I’m forwarding SSH from VPS to home, I’d have the VPS running HAProxy listening on port 22. Then I’d have it forward to home on port 220. Then, on the home server, you run this amazing piece of software called go-mmproxy. Configure that to listen on port 220 and forward to localhost 22. And there you have it.

HAProxy passes the real source IP to go-mmproxy with the proxy protocol, go-mmproxy takes the proxy header and strips it from the request, spoofs the source IP address from localhost to the real source IP contained in the proxy header then makes the request to localhost. And then you also have to configure traffic to go back through localhost so go-mmproxy can pick it up and add the proxy header back to the request, to be sent back to the source.

[–] nickshanks 1 points 1 year ago (1 children)

Would this work for my use case? I just want a service to be able to see the real source IPs but still going through a proxy

[–] nickshanks 0 points 1 year ago (1 children)

Okay, can we go back to those iptables commands?

iptables -t nat -A PREROUTING -d {VPS_PUBLIC_IP}/32 -p tcp -m tcp --dport {PORT} -j DNAT --to-destination {VPN_CLIENT_ADDRESS}
iptables -t nat -A POSTROUTING -s {VPN_SUBNET}/24 -o eth0 -j MASQUERADE

Just to confirm, is the -o eth0 in the second command essentially the interface where all the traffic is coming in? I've setup a quick Wireguard VPN with Docker, setup the client so that it routes ALL traffic through the VPN. Doing something like curl ifconfig.me now shows the public IP of the VPS... this is good. But it seems like the iptables command aren't working for me.

[–] nickshanks 1 points 1 year ago (3 children)

Thanks, this helps a lot. So in your OpenVPN config, on the client, do you have it to send all traffic back through the VPN?

[–] nickshanks 1 points 1 year ago (5 children)

Everything I use is in Docker too, I'd much rather use Docker than mess around with host files, but to try it out I don't mind. If you have an image you could share, I'd appreciate it.

Anyway, neither are clients or servers as I just used ZeroTier as a quick setup. On my other infra I use wireguard with the VPS being the server (that setup works well but I only reverse proxy HTTP stuff so X-Forwarded-For works well).

[–] nickshanks 0 points 1 year ago (2 children)

Do I need to specify to forward VPN traffic through my router and then traffic to 0.0.0.0/0 through the VPN?

[–] nickshanks 1 points 1 year ago (10 children)

Thank you so much for the quick and detailed reply, appreciate it!

Done all of the iptables stuff, just trying to change the default gateway on the server at home now:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: true
      routes:
        - to: 0.0.0.0/0
          via: <vps public ip>

Does the above netplan yaml look right? When it's applied, I can't access the internet or even the VPS public IP.

 

Simple question, difficult solution. I can't work it out. I have a server at home with a site-to-site VPN to a server in the cloud. The server in the cloud has a public IP.

I want people to access server in the cloud and it should forward traffic through the VPN. I have tried this and it works. I've tried with nginx streams, frp and also HAProxy. They all work, but, in the server at home logs I can only see that people are connecting from the site-to-site VPN, not their actual source IP.

Is there any solution (program/Docker image) that will take a port, forward it to another host (or maybe another program listening on the host) that then modifies the traffic to contain the real source IP. The whole idea is that in the server logs I want to see people's real IP addresses, not the server in the cloud private VPN IP.