I was under the impression that HTTP_HOST would be populated with the Host header the client provides. The documentation seems to support this:
arbitrary request header field; the last part of a variable name is the field name converted to lower case with dashes replaced by underscores
Regardless though you should configure Nginx to support multiple host names within the viritual host:
server_name example1.com example2.com;
In your post above you were overriding
$_SERVER['SERVER_NAME'] in Nginx’s conf files but still checking
$_SERVER['HTTP_HOST'] when inside PHP.
Nonetheless, if you need to pass this to the PHP interpreter, then create a variable like
X-CLIENT-HOST (i.e. something non-standard so as not to interfere with anything else) then do the check in
config.php as I detailed above to only allow approved host names.
Just set the frickin’ constant and walk away. The whole point of that constant is to handle edge cases gracefully. Why create all this work unnecessarily because you don’t want to define a single value as true and skip the checks?