Passthrough gitea SSH through two servers
For the love of god i wasn't able to make this work.
I have three servers which live on two different networks:
- gitea server (10.0.0.10 [eth0]) - Alpine Linux
- local proxy server (10.0.0.3 [eth1], 10.22.33.2 [wg0]) - Alpine Linux
- reverse proxy server (10.22.33.1[wg0], public internet IP [eth0]) - Debian
Currently there is haproxy running on the local proxy server listening on :80 which just blindly forwards stuff between various servers on the 10.0.0.0/24 class which is then properly cached and served by a nginx-based SSL terminator. However, I am now encountering an issue.
The gitea server runs a SSH server on port 22000, which is needed to let people authenticate via SSH, and for the love of got i cannot seem to be able to forward it in any way. I have tried the following rule on the local proxy server:
iptables -t nat -A PREROUTING -i wg0 -p tcp --dport 22000 -j DNAT --to-destination 10.0.0.10:22000
But even from the reverse proxy server (reaching from wg0) i am not able to connect (connection refused) to the server. If i run an http server on the local proxy server (python3 -m http.server 22000), i can properly access it both from gitea and reverse proxy.
Of course port forward is enabled.
I also tried haproxy tcp forwarding, but didn't understand much how to set it up.
What should I do?
tldr: ssh server on gitea, how can i expose it to the internet?
Comments
Local proxy can reach the server and seems to have the rule enabled:
But on the reverse proxy:
Hangs forever.
I have discovered the existance of socat, and stopped trying to relay packets around
https://www.redhat.com/sysadmin/getting-started-socat
I think it might be that the gitea server only has a route table for it's own subnet 10.0.0.0/24, and it does not know to route to 10.22.33.1 (which is on the separate wireguard subnet)