There are plenty of valid reasons to want to use a reverse proxy for SSH:
- Maybe there is a Forgejo instance and Gitea instance running on the same server.
- Maybe there is a Prod Forgejo instance and Dev Forgejo instance running on the same server.
- Maybe both Forgejo and an SFTP are running on the same server.
- Maybe Forgejo is running in a cluster like Docker Swarm or Kubernetes
- Maybe there is a desire to have Caddy act as a bastion host due to an inability to run a true bastion host for SSH or reduce maintenance of managing yet another service/server in addition to Caddy
Regardless of the reason, your last point is valid and the real issue here. I do not think it is possible for Caddy to reverse proxy SSH traffic - at least not without additional software (either on the client, server, or both) or some overly complicated (and likely less secure) setup. This may be possible if TCP traffic included SNI information, but unfortunately it does not.
I feel silly for not realizing that the SSH config would be used by Git!
I thought if Forgejo’s SSH service listened to a non-standard port that you would have to do commands with the port in the command similar to below (following your example). I guess I assumed Git did not directly use the client’s SSH service.