apachesubdomainvhostsdyndns

Multiple subdomains and servers behind single DynDNS name?


I've got a dynamic IP from my ISP so I'm using a free DynDNS service to redirect traffic to my server. I just bought a Raspberry Pi and would like to reach it from the outside too, preferrably with another subdomain. Can I use multiple CNAME records pointing at the DynDNS domain and then put a VHOSTS file in the servers to direct traffic to the right server depending on the subdomain called?

Or is it the DynDNS subdomain that calls the server rather than my own subdomain, i.e. showing the same id to the server independent of the subdomain called by the user? I'd rather not use different ports for different servers handling the same protocol.

Today:
server.example.com -> CNAME -> server.dyndns.com -> 1.2.3.4 -> home server

Future:
server.example.com -> CNAME -> server.dyndns.com -> 1.2.3.4 -> home server
rpi.example.com -> CNAME -> server.dyndns.com -> 1.2.3.4 -> raspberry pi


Solution

  • Ya I think you would just use CNAME records to point all of your sub domains to the same dyndns sub domain and then handle differentiating them all with vhosts. As for your raspberry pi, you might have to have a vhost on your apache web server that would act like a proxy server, sending all traffic from a hostname (sub domain) to the pi's ip. Here's an example of a vhost proxy configuration (goes in Apache's config, probably httpd.conf)

    <VirtualHost *:80>
        ServerName rpi.example.com
        ProxyPass         /  http://localhost:8080/
        ProxyPassReverse  /  http://localhost:8080/
    </VirtualHost>
    

    Replace localhost and port number with the ip and port of the raspberry pi