Hostname in Root directive.
Francis Daly
francis at daoine.org
Fri Jul 19 15:41:48 UTC 2013
On Fri, Jul 19, 2013 at 10:55:57AM -0400, David | StyleFlare wrote:
Hi there,
> I know this may not be safe, but how can I set the hostname in the root
> directive
> ie; root /www/$hostname/static;
By using a variable, just like you've done there.
Two things you need to decide:
what exact variable do you want to use? (There's a list of core-module
pre-defined variables at
http://nginx.org/en/docs/http/ngx_http_core_module.html#variables
for example);
and do you want to accept whatever that variable happens to hold, or do
you want to use something like a map (http://nginx.org/r/map) to set it
to a default value if it doesn't have a "safe" value, where you define
"safe"?
"hostname" might be $http_host, or $host, or $server_name (with increasing
amounts of trust), or maybe something else entirely.
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list