I've got this weird problem that I don't understand. I used the EE engine script to install a wordpress blog at linode, using NGINX. This has worked well in the past.

The script installs a VHOST for my domain name (let's call it example.com) and the end result in the /etc/nginx/sites-available is :

  • default
  • example.com
  • 22222 (admin tools, these are not the issue)

The problem :

After setting up the DNS in linode everything seemed to work fine. Example.com pulled up the WordPress blog with no issues. However, at my office location, NGINX would revert back to default ! ... So, at home and everywhere else, there was no problem, while in some other locations (like the office), NGINX would give me the default index.xxx (with the NGINX is working message). Same, laptop, same browser, same everything, but different resolving, depending on which physical location I am in.

Solution 1 :

Forcing NGINX to use example.com by making it default_server in the config. This works, however it should not HAVE to be the way to solve it, since NGINX should catch the domain name and serve correct site. How else can I trust it to serve the correct pages whenever I setup more sites on it in the future ?

Solution 2 :

The file : etc/nginx/sites-enabeled/default has the following lines :

# Default server configuration
server {
        listen 80 default_server;
        listen [::]:80 default_server;

        # SSL configuration
        # ......

Whenever I comment out the second listen directive, namely :

listen [::]:80 default_server;

And I leave the first one in, then NGINX resolves my domain name CORRECTLY, while /etc/nginx/sites-enabled/default is STILL the default_server.

This seems to be CORRECT behavior, am I right ?

The question:

So, now I would like to know if this is really the correct behavior, why this is so, and if this has been a bug or just a misconfiguration.

Bug ??? : because with the original config (including the second directive), NGINX used to revolve correctly from my house, but NOT from my workplace location (same laptop, browser, etc, etc,). Inconsistent

Mis-config ???? : You tell me why that is so, when before it used to not resolve correctly only from my workplace ...


My guess would be that you don't have an IPv6 listen directive in the example.com server config but use IPv6 to access the site in the locations where it doesn't work.

In that case, the listen [::]:80 default_server; directive catches the request, as there is nothing matching for example.com. If you remove this line, the server falls back to IPv4 entirely and everything works.

The correct solution in that case would be to add listen [::]:80 to the example.com server stanza.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.