I'm trying to use a variable in nginx in server_name
, but is not working. Is this possible?
server { listen 80; index index.php index.html; set $foo "bar.example.com"; server_name $foo; }
No it's not possible unless you want to set it to exactly the $hostname variable.
Ref:
To set the server name in Nginx to the virtual machine name, you can use the built-in variable $hostname.
server { listen 443 ssl; server_name $hostname; }