Welcome! Log In Create A New Profile

Advanced

Re: server_name host order

Maxim Dounin
November 23, 2011 08:44AM
Hello!

On Wed, Nov 23, 2011 at 05:30:46AM -0500, token wrote:

> Hello, I would like to know if this is correct
>
> Will NGINX allways return the first of the provided hostname name in
> from the `server_name` as beign the "SERVER_NAME",
>
> eg server_name hostname1 hostname2;

The $server_name variable is always first name as defined by the
"server_name" directive in the server{} in question.

With default fastcgi_params as shipped with nginx, SERVER_NAME as
passed to php via fastcgi will be set to $server_name, i.e. first
name defined with the "server_name" directive.

> I have two server blocks in this example
>
> server {
> listen 80;
> server_name www.example.co.uk *.example.co.uk;
> }
>
> the URI = http://something.example.co.uk/
>
> // PHP APPLICATION --------------
> I see as expected `SERVER_NAME` and `HTTP_HOST`
>
> SERVER_PORT => 80
> SERVER_NAME => www.example.co.uk
> HTTP_HOST => something.example.co.uk
> --------------
>
> server {
> listen 443;
> server_name www.example.co.uk secure.example.co.uk;
> }
>
> // PHP APPLICATION --------------
> again the `SERVER_NAME` and `HTTP_HOST` as i would expect
>
> the URI = https://secure.example.co.uk/
>
> // SERVER_PORT => 443
> // SERVER_NAME => www.example.co.uk
> // HTTP_HOST => secure.example.co.uk

Yes, this is correct and expected behaviour.

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

server_name host order

token November 23, 2011 05:30AM

Re: server_name host order

Maxim Dounin November 23, 2011 08:44AM

Re: server_name host order

token November 23, 2011 08:55AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 164
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready