If server_name is something like “*”, $server_name is exactly “*”. If $server_name is passed on to fastcgi_param as SERVER_NAME, in the program, for example, php $_SERVER[‘SERVER_NAME’] will be exactly “*”. However, _SERVER[“HTTP_HOST”] shows the value most of us would expect, i.e. the host name in the address bar.

In Nginx, I have set up a mechanism to install some popular scripts once, and use in multiple websites. I do not want people to find these websites are run under one roof. But if I write multiple websites in one line:


$_SERVER[‘SERVER_NAME’] is always assigned no matter the host is or

To avoid that, I have to break three websites into three server block in nginx.

$_SERVER[‘HTTP_HOST’] is always the host. But I can not control how people write the script. Breaking hosts into separate server blocks is recommended.

Leave a comment

Your email address will not be published. Required fields are marked *