Scenario
I have a website served by nginx listen at domain myabc.domain.com.
The nginx configuration is:
server {
listen 443 ssl;
server_name myabc.domain.com`;
root /home/ubuntu/portal;
location / {
# other directives
}
Then I add an A record in DNS server:
myabc.domain.com -> 123.123.123.123
It is working fine.
Then, I add a CNAME record to DNS server
myabc2.domain.com -> myabc.domain.com
I tried accessing the webpage from browser with myabc2.domain.com and it works!?
Question
I expect the nginx server_name to only permit access to this site whose host header is myabc.domain.com.
The host header is set automatically by browsers to be the one I typed in. (I assume)
So why doesn't nginx deny access to this request?
server_nameis found, the request will be routed to the first server - which is themyabc.domain.comserver in my setting.