Nginx catching all domains without wildcard

B.R. reallfqq-nginx at yahoo.fr
Mon Dec 28 12:41:16 UTC 2015


In the configuration you provided, there are 3 server blocks:
- 80 www.domain.com
- 443 (default server) domain.com
- 127.0.0.1:8081 elsitar.com

There is no server block defined for uk.domain.com (you main config file
has an include directive for a /etc/nginx/uk.domain.com file which is
commented though), thus a default server block will be selected.

On port 443, for all IP addresses, the domain.com server block will be
chosen as it is defined as being the default.
On port 80, there is no default port defined, thus the first (and only) one
will be used.
On 8081 for the localhost IP address 127.0.0.1, as for 80, there is no
default port so the first (and only) server block defined for the IP:port
pair will be selected as the default.

There is no magical behavior, please make sure you understand the docs.
There is even a webpage dedicated to server names:
http://nginx.org/en/docs/http/server_names.html
---
*B. R.*

On Mon, Dec 28, 2015 at 3:52 AM, Xavier Cardil Coll <info at elsitar.com>
wrote:

> My Nginx config is catching all subdomains without specifying a wildcard.
> I have created an special config for each subdomain, but seems that all
> subdomains pass trough the main domain configuration. I have discovered
> this by removing the subdomains configuration files from nginx.conf and
> watching how it still catches all the subdomains, so when I send a request
> to uk.domain.com, instead of Nginx catching the subdomain configuration,
> goes through the main domain configuration. This is causing trouble with
> applying mod_pagespeed individually to each of the sites and also managing
> the GA universal code.
> The config for the main domain is this :
>
> http://pastebin.com/4AvGgRCc
>
> http config :
>
> http://pastebin.com/CkJLHyHH
>
> If I haven't setup a wildcard, how come the main domain config is catching
> all subdomains ??
>
> Thanks
>
>
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20151228/c0abe97f/attachment.html>


More information about the nginx mailing list