Show real server name in nginx logs and params passed to fastcgi?
I have configured my nginx vhosts with a regex in server_name. nginx shows the raw regex in logs and in params passed to php-fpm (I know there's $_SERVER['HTTP_HOST']
with a real value, that's not an issue). My question is how can I get nginx to put the real hostname to logs, instead of the regex.
The server_name directive looks like this:
server_name ~^(:?(?<second>.+)\.)?(?<domain>[^.]+\.[^.]+)$;
Use $http_host
in your log_format
to get the actual host that the client sent.
You can also use that variable in access_log
directives to split your logs by hostname.