Forum: NGINX server_name

Posted by Marcos Neves (Guest)
on 2009-11-05 05:05
(Received via mailing list)
I use this:

server {
  server_name _;
  server_name_in_redirect off;
  fastcgi_param  SERVER_NAME        $server_name;
}

but when I inspect $_SERVER["SERVER_NAME"] I get this "_", but I would
like to get the domain name, so I change to this:

fastcgi_param  SERVER_NAME        $host;

But, is this the right thing to do?

Marcos Neves
+55 44 9918-8488
Posted by Соколов Евгений (Guest)
on 2009-11-05 05:51
(Received via mailing list)
Hi

try use $_SERVER["HTTP_HOST"] for host, and use "server_name  _" for
$_SERVER["SERVER_NAME"].

I think it's more right way for your case


2009/11/5 Marcos Neves <marcos.neves@gmail.com>:
Posted by Anton Yuzhaninov (Guest)
on 2012-11-21 05:39
(Received via mailing list)
On 11/20/12 15:31, Gregory Edigarov wrote:
>>
>> try_files /subdoms/$subdom @fallback;
>>
> ,  -  .
>    fallback.
> /subdoms/$subdom -     ,    ?

  try_file    :

root /subdoms/$subdom;
...
try_file $uri $uri/ @fallback;

--
  Anton Yuzhaninov
Posted by Gregory Edigarov (Guest)
on 2012-11-21 05:49
(Received via mailing list)
On 11/20/2012 01:35 PM, Anton Yuzhaninov wrote:
>
> root /subdoms/$subdom;
> ...
> try_file $uri $uri/ @fallback;
>
-  .  $subdom   .  ????
Posted by Gregory Edigarov (Guest)
on 2012-11-21 05:51
(Received via mailing list)
On 11/20/2012 01:46 PM, Gregory Edigarov wrote:
>>   try_file    :
>>
>> root /subdoms/$subdom;
>> ...
>> try_file $uri $uri/ @fallback;
>>
> -  .  $subdom   .  ????
  /subdoms/$subdom - 100%
Posted by Ruslan Ermilov (Guest)
on 2012-11-21 07:47
(Received via mailing list)
On Tue, Nov 20, 2012 at 01:48:59PM +0200, Gregory Edigarov wrote:
> >>
> >>   try_file    :
> >>
> >> root /subdoms/$subdom;
> >> ...
> >> try_file $uri $uri/ @fallback;
> >>
> > -  .  $subdom   .  ????
>   /subdoms/$subdom - 100%

  root /subdoms/$subdom  /subdoms/$subdom
    .       ?

 "try_files /subdoms/$subdom"   ,  ,
.. try_files   root,     ,
    /.

  ,   :

server {
server_name ~^(.*).example.com$;
location / {
root /tmp/foo/subdoms/$1;
try_files $uri $uri/ =404;
}

$ grep ^ /tmp/foo/subdoms/test*/*
/tmp/foo/subdoms/test1/foo:foo
/tmp/foo/subdoms/test1/index.html:this is test1
/tmp/foo/subdoms/test2/index.html:this is test2
$ curl http://test1.example.com:8000/
this is test1
$ curl http://test2.example.com:8000/
this is test2
$ curl http://test1.example.com:8000/foo
foo

(    ,
     .)
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.