In my Nginx configuration there’s
server_name ~^(?<domain>.*mygreatsite987778.com.invalid)$ ;
Which works quite good. But When Php does echo $_SERVER['SERVER'], it sees:
~^(?.*mygreatsite987778.com.invalid)$
Despite it seems logical, is there a way to get the server name that matched the regex? The server variable HTTP_HOST contains the good value (stuff.mygreatsite987778.com.invalid). I’d like to keep the SERVER variable.
Those variables are defined in your Nginx configuration file. You can set them to any value you require.
The variable you are looking at (which on my system is called
SERVER_NAME) is using the value of the$server_namevariable, but you would prefer to use the value of the$hostor$http_hostvalue.Most of these variables are defined in a file called
fastcgi_params, but you can override them individually by placing a statement after the include statement.For example: