3

My goal is to use GitHub Pages and also benefit from their CDN, without having to use a third-party DNS host that supports DNS ALIAS record types (or ANAME - neither are accepted standards). I want to know how they do it, can anyone explain please?

We have many questions here about DNS aliasing with CNAME records, but in this particular situation I can't CNAME the naked domain to username.github.io.

If I do this with Apache or Nginx to get www.example.com working as a GitHub Page, does it work and do I break anything like email?

Apache

<VirtualHost *:80>
        ServerName example.com
        Redirect 301 / http://username.github.io/
</VirtualHost>

Nginx

server {
    server_name example.com;
    return 301 http://username.github.io/;
}

The above assumes a CNAME for www => username.github.io and an A Record for the naked domain => one of my servers with the above configuration.

  • So... Instead of breaking the standards (by using ANAME/ALIAS) you want to break the standards (by using an apex CNAME)? – Mathias R. Jessen Jan 9 '14 at 21:48
  • 2
    wwwizer.com – Michael Hampton Jan 9 '14 at 21:54
  • @MathiasR.Jessen Possibly...yes! If all I'm doing is breaking a standard (but achieving the functionality I want) then that's okay for now. If I'm actually breaking any functionality with the domain then no. It's not like I'm proposing to drive on the wrong side of the road or tear the warning tags off of mattresses. – Tom Brossman Jan 9 '14 at 23:11
  • @MichaelHampton interesting, that might be the simplest. – Tom Brossman Jan 9 '14 at 23:13
1

without having to use a third-party DNS host that supports DNS ALIAS record types (or ANAME - neither are accepted standards)

This sentence is meaningless. In both the mentioned cases, the ALIAS and ANAME custom DNS types are internally resolved into a pool of A records. Thus, from an end-user perspective, you are not breaking any standard. Any client trying to connect to a hostname you configured with an ALIAS (I can speak for DNSimple given I'm work for them) will return the same list of A record that would return the target hostname.

but in this particular situation I can't CNAME the naked domain to username.github.io.

Theoretically you can, practically you don't want to. Per RFC, the CNAME can't co-exist with any additional record type. This means that if you CNAME the root domain you will shadow any other record associated to the root domain basically breaking your root domain capability to resolve.

If I do this with Apache or Nginx to get www.example.com working as a GitHub Page, does it work and do I break anything like email?

You can configure www.example.com as CNAME as long as you don't need any other DNS record attached to that hostname. This is normally ok.

From a web server configuration there is nothing you need to do. If you configure www.example.com as a CNAME of username.github.io, any request to www.example.com will resolve to the IP(s) associated with username.github.io and GitHub web servers will handle the request.

Still, in this case you haven't solved the problem of what you want to do with the root domain. At this point, the only think you can do is to HTTP redirect the root domain to the www.example.com hostname.

The configuration snippets you mentioned will work in that way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.