Multiple DNS entries pointing to different 'parts' of a server

0

I want to have two subdomains:

a.myawesomewebsite.com
b.myawesomewebsite.com

point to different 'parts' of a VPS I have. One 'part' is the HTTP server running on that server, the other is an SSH tunnel to my home server where all the bigger and less used files are stored. Is there a way to do this?

Note: I cannot point it to my home server directly as my ISP NATs all the internet traffic to one server in London so, obviously, no port forwarding and I have to use an SSH tunnel.

Thanks in advance.

Jachdich

Posted 2019-04-16T20:55:53.397

Reputation: 135

Are you asking specifically about two websites (HTTP/HTTPS), i.e. two services on the same TCP port? – user1686 – 2019-04-17T04:52:29.657

@grawity Yes that is correct – Jachdich – 2019-04-17T06:44:35.177

Answers

1

I will have to assume you're asking about two websites (that is, the home SSH tunnel leads to another HTTP server), because the question makes the most sense that way.

So if you want http://a.example.com and http://b.example.com to lead to different websites through the same server, you have two options:

  • Configure your web server as a "reverse proxy". Both nginx and Apache are capable of this and support per-domain and per-URL configuration – so you can have one VirtualHost that just serves your normal website on domain A, and a second VirtualHost that will proxy requests to your SSH-tunneled host.

    (It is the same as having two 'normal' domains on the same web server, the only difference is the additional ProxyPass parameter.)

    If your current web server does not support a reverse-proxy feature, then you can install a reverse proxy in front of it instead (either the same Apache/nginx, or something dedicated like haproxy).

  • Purchase a second IPv4 address for your server machine, then configure the web server to listen for connections on ("bind to") one of those addresses, and bind the SSH tunnel to the other. Point each DNS domain to the corresponding IPv4 address.

user1686

Posted 2019-04-16T20:55:53.397

Reputation: 283 655

I don't know what a reverse proxy is, but I'm sure there's a few tutorials out there :) and I'll try it out and see if it works. I'd like to stay away from getting multiple IPs, but if that's the only option then it'll probably be ok – Jachdich – 2019-04-17T06:47:17.993

It's a webserver that forwards requests to another webserver. There are plenty of tutorials for configuring a reverse proxy, but if you use Apache or nginx, then start with just making the webserver recognize both domains in general – once you have that, turning the 2nd domain from local into proxy is a matter of adding just one or two Proxy* options. – user1686 – 2019-04-17T06:48:40.010

Ok that doesn't sound too complicated. I'll give it a try when I have half an hour spare. – Jachdich – 2019-04-17T07:01:22.820