Forum: NGINX Hostname in Root directive.

2f3eba0d21797057561428c593c438fb?d=identicon&s=25 David | StyleFlare (Guest)
on 2013-07-19 16:56
(Received via mailing list)
I know this may not be safe, but how can I set the hostname in the root
directive

location /static {
ie; root /www/$hostname/static;

}
36a8284995fa0fb82e6aa2bede32adac?d=identicon&s=25 Francis Daly (Guest)
on 2013-07-19 17:42
(Received via mailing list)
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...

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@daoine.org
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.