I have servers with different services. Each service has its own ssh server to access to the service. Each ssh server it in a different port (e.g. 2022 and 3022).

Also, I have different domains to access the services. (a.dom.com, b.dom.com). The IP of both domains is the same ( but I use the domains, with a reverse proxy, to access to different services.

It is possible to create a reverse proxy for ssh server too, that redirect a port (e.g. 22) to other ports depends on the domain.

My objective is that I can do ssh a.dom.com and ssh b.dom.com

I have tried with ssh tunnelling, with the following command: (Think that I have a third ssh server in the port 23)

ssh -p 23 localhost -R a.dom.com:22:localhost:2022 -R b.dom.com:22:localhost:3022

but It didn't work and I think that it is not correct because, in the command, the a.dom.com is an IP filter for the tunnel


1 Answer 1


That is not possible this way: The IP address of the domain names is looked up first, and if both a.dom.com and b.dom.com map to the same IP address, the packets that arrive at the reverse proxy will be identical, so there's no way to map them to different ports.

If the domains had different IP addresses, and you had a single reverse proxy responding to all these IP addresses, it would be possible (google "port forwarding").

If all you want is simplify accessing the services via ssh, I suggest that instead you edit your ssh_config files with entries like these:

Host a
    HostName a.dom.com
    Port 2022

Then you can just do ssh a and it will automatically pick the correct port. You can even add a User fhuertas line if you need a different user name.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .