HTTP servers like nginx are able to proxy based on the hostname because it is sent in the HTTP/1.1 Host header of the request. SSH does not have this concept of virtual hosts, the client not send the hostname at all.
You have three options:
- Use port forwarding to make your gitlab server directly available.
- Make your gitlab server available through an (additional) IPv4 or IPv6 address.
- Create a SSH tunnel into your network and proxy the SSH connection to your git server through this tunnel.
This is probably the easiest approach that does interfere with the "public server". Setup your gateway to forward port 2222 to 192.168.2.26:22. Then use the
ssh -p2222 firstname.lastname@example.org to connect. For
git, use URLs like
Alternatively, you can just use
email@example.com:repo.git if you create a
~/.ssh/config file with:
Additional IPv4 or IPv6 address
If you have a home network, getting an IPv4 address is probably impossible, but some business providers do it. If your network supports IPv6 (end-to-end), then you can just use normal routing without nasty proxying or NAT hackery.
You can use the
ProxyCommand option to specify the command that proxies the SSH connection to
git.example.com. In your case, the "public server" is the proxy, so the command should be connecting to that server.
Let's start with the configuration snippet for
ProxyCommand ssh -W %h:%p firstname.lastname@example.org
In this snippet the
-W %h:%p option will be expanded to
-W git.example.com:22 and redirect standard input and output to said host (git.example.com). This enables your local SSH client to speak with your gitlab server. You can again use any URL like
email@example.com:repo.git, the proxy will be transparant to the git client.