How to connect to ssh server with domain name

40 views Asked by At

I've built a physical server running Ubuntu that I want to use to host websites and games from my home network. I have a domain registered on namecheap, configured with a DDNS address record to point to my home network, and routing through cloudflare. Ports 80 and 22 are forwarded by my router and enabled on the server's firewall. My current goal is to be able to gain ssh access using 'ssh [email protected]' and to be able to connect to game servers using 'play.domain.com/gamename' as the server's ip.

So far I've been struggling to get this setup to work using the nginx stream module. This is the stream section of my current nginx config (for now I'm keeping it in the base config):

stream {
    upstream ssh {
        server localhost:22;
    }

    server {
        listen 80;
        proxy_pass ssh;
    }
}

A note on this: I originally tried to listen on port 22 (with that port forwarded and enabled on firewall), and that would not connect.

I'm aware that using cloudflare may mean that I'm trying to ssh into cloudflare and not my actual server. I have temporarily turned off the proxy for my domain but it still doesn't work. Apologies in advance if this is just a misunderstanding of how cloudflare works.

I've tried many different settings but haven't been able to simply point 'ssh.domain.com' to my ssh server running on a machine on my home network. My questions are: How can I configure nginx to route my subdomain 'ssh.domain.com' to my ssh server? If this is not feasible with nginx, what other tool should I use to get the job done?

0

There are 0 answers