2

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

Zarkov
  • 23
  • 1
  • 4
  • That certainly is possible. from a technical point of view. But DynDNS does not offer usage of second level domains like that. Most likely you have an account there resolving to something like myserver.dyndns.org. Then you _can_ use rpi.myserver.dyndns.org as virtual host. What you _cannot_ do is have such "subdomains" resolve to different internal ip addresses, since that would mean that the _router_ would have to evaluate the `host` header inside the http protocol which does not work. – arkascha Feb 12 '14 at 08:44
  • I dont intend to use second level subdomains with my DynDNS address, I want to direct several first level subdomains to my single IP and then split them to different servers. My intention is to have the VHOSTS file resolve which server to use, _if_ the host header contains my own subdomain name rather than just the DynDNS name (which is what my question is all about). – Zarkov Feb 12 '14 at 09:24
  • Ok, no problem then. But what _is_ the problem in this case? – arkascha Feb 12 '14 at 09:27
  • I want to know if the `host` header shows my subdomain name rather than the DynDNS name. If so, I can use VHOSTS to separate traffic to different servers. – Zarkov Feb 12 '14 at 09:30
  • Sure you can! The `HOST` header sent by browsers will always contain the name of the domain as specified in the URL. Not more, not less, it is simply handled as a string. You can easily test that yourself by sniffing a request or using a web debugging proxy. – arkascha Feb 12 '14 at 09:31
  • 1
    Perfect, thats just what I wanted to hear! – Zarkov Feb 12 '14 at 09:34

1 Answers1

2

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

Scotty Waggoner
  • 3,083
  • 2
  • 26
  • 40