Welcome! Log In Create A New Profile

Advanced

Re: Nginx server_name command being ignored

Jonathan Matthews
December 14, 2012 08:10AM
On 14 December 2012 13:01, constable1 <nginx-forum@nginx.us> wrote:
> Hi, I'm running ubuntu server 12.04 and the latest version of nginx. The
> problem I am having is that nginx seems to be ignoring the server_name
> command, I am able to access the server by going to the IP address of the
> server or by going to the server's name (http://ubuntuserver/) but
> http://test/ will give me nothing, no connection, not even an error page. I
> have checked that the website file (in enabled-sites) is included in the
> nginx.conf file and I have correctly restarted nginx having changed
> settings. I have tried with the whole server block stripped down to just the
> server_name designation and still I can't get anything at http://test/ and
> in this case I get an expected error page on http://ubuntuserver/
>
> I can only deduce that for some reason the "server_name" command is being
> ignored!

I really doubt it is. It's an absolute cornerstone of how nginx works.

a) Does your machine resolve the correct IP address when asking your
hostsfile/DNS/etc for "test"? server_name doesn't automatically point
your browser towards the correct machine ...

b) The first server{} stanza for an IP:port pair is the default one
served when a request comes in on that IP and port, and the Host
header doesn't match /another/ server_name configured elsewhere for
that same IP and port. Unless there's a dedicated default server ...

You may wish to set up a sacrificial default server to make nginx's
behaviour more obvious.
This is roughly what I have (typed but not tested, FYI):

server {
listen 80 default_server;
server_name _;
return 400 "Server not configured";
}

HTH,
Jonathan
--
Jonathan Matthews // Oxford, London, UK
http://www.jpluscplusm.com/contact.html

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

Nginx server_name command being ignored

constable1 December 14, 2012 08:01AM

Re: Nginx server_name command being ignored

Antonio P.P. Almeida December 14, 2012 08:10AM

Re: Nginx server_name command being ignored

Jonathan Matthews December 14, 2012 08:10AM

Re: Nginx server_name command being ignored

constable1 December 14, 2012 08:12AM

Re: Nginx server_name command being ignored

Jonathan Matthews December 14, 2012 08:20AM

Re: Nginx server_name command being ignored

constable1 December 14, 2012 06:54PM

Re: Nginx server_name command being ignored

Jonathan Matthews December 14, 2012 07:24PM

Re: Nginx server_name command being ignored

constable1 December 14, 2012 08:20PM

Re: Nginx server_name command being ignored

Francis Daly December 15, 2012 06:08AM

Re: Nginx server_name command being ignored

constable1 December 15, 2012 06:32AM

Re: Nginx server_name command being ignored

Francis Daly December 15, 2012 06:48AM

Re: Nginx server_name command being ignored

constable1 December 15, 2012 07:01AM

Re: Nginx server_name command being ignored

Francis Daly December 15, 2012 09:12AM

Re: Nginx server_name command being ignored

Francis Daly December 14, 2012 08:14AM

Re: Nginx server_name command being ignored

Francis Daly December 14, 2012 08:34AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 227
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