William DA SILVA
Web Developer

Today I learned CNAME and Nginx server name

Written on: Dec 24, 2020 • Last update: Dec 24, 2020

CNAME ≠ redirection

One silly thing I learned today is that you cannot get the CNAME walkthrough when you get a request in your server. When doing a CNAME from the domain first.tld to second.tld and second.tld points to my server IP A 127.0.0.1 . By doing that, you cannot know that the request received in your server goes through second.tld since you receive only the first.tld as host.

That makes cense because all the DNS stuff is resolved before reaching the server so it's impossible to know that it went to second.tld when receiving the request.

It think I confused a CNAME record with some sort of redirection but it's not. As I understand CNAME records, it's just a DNS record to know what IP the user should go.

Nginx "_" server name

Another thing I learned today is that the _ Nginx server_name does not what we may think it does. As I understand it, to catch any domain, the server must be default_server.