Possible bug in value of $server_name variable

I have “server_name .domain.tld" in my config file and tried to get the
correct virtual host the user connected to with the help of a php script
but “$_SERVER[‘SERVER_NAME’]” returned "
.domain.tld” instead of
“something.domain.tld” when I connect to it.

When I use “.domain.tld” instead of “*.domain.tld” I get “domain.tld” as
the hostname.

Is this is bug or how to get the real hostname the user connect to ?

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,223642,223642#msg-223642

On Thu, Mar 08, 2012 at 12:55:15PM -0500, Kaimei wrote:

Hi there,

Is this is bug or how to get the real hostname the user connect to ?

The nginx variable $server_name is the first name in the server_name
directive list.

The nginx variable $http_host is the Host: header sent by the client.

The nginx variable $host is $http_host if it is defined, and
$server_name
if not.

The typical nginx fastcgi configuration will set SERVER_NAME to
$server_name (within fastcgi.conf) and HTTP_HOST to http_host (because
that’s what happens to client headers). So you can check those in
your script.

If you wish, you can add your own “fastcgi_param HOST $host” setting
and check that, or you could set SERVER_NAME to be $host and continue
checking that one.

f

Francis D. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs