Best way to handle preprod server_names

B.R. reallfqq-nginx at yahoo.fr
Wed May 16 16:47:28 UTC 2012


Hello,

Typically, I would use one directory per host to serve content from each
domain and use one config file per generic type:
http {
  listen 80;
  root /var/www/$host;

  server { # Include that section from a separate file
    server_name ~^[[:alnum:]]+(\.[[:alnum:]]+
)*\.preprod\.domain[0-9]*\.com$;
    # Pre-production rules
  }

  server { # Include that section from a separate file
    server_name ~^[[:alnum:]]+(\.[[:alnum:]]+)*(!\.preprod)\.domain[0-9]*
\.com$;
    # Production rules
  }
}

You can then create server bloc listening to specific subdomains for
particular case, i.e.:
server {
  server_name test.preprod.domain42.com;
  # Rules here have higher priority than the generic rules since the
server_name uses an exact match comparison
}

You will have to work further on regex to be sure they do what you want
them to do. ;o)
---
*B. R.*


On Wed, May 16, 2012 at 5:08 AM, Greg <greg at 2lm.fr> wrote:

>  Hi,
>
> I'm going to migrate a lots of vhosts from Squid+Apache2 to NginX, step by
> step.
> First step is to migrate just NginX and few static vhosts.
>
> Actually there is ~600 domains x 5 vhosts + equivalent for preprod. So I
> wrote a NginX vhost for ".mydomain1.com .mydomain2.com" and so on with
> the 600 domains.
>
> Question is, how the best practices to have this domains for our preprod
> which looks like ".preprod.mydomain1.com" for each domains.
>
> Preprod has specific config like gzip disabled (for internals purpose...).
>
> Actually, prod's config looks like :
> server {
>     server_name .mydomain1.com; # main domain
>     include                                 /etc/nginx/domains.conf;
>     server_name_in_redirect                 off;
>     include                                 common/prod.conf
> }
>
> And domains.conf :
> server_name
> .mydomain1.com
> .mydomain2.com
> ...
> ;
>
> Preprod could have this config :
> server {
>     server_name .preprod.mydomain1.com; # main domain
>     include
> /etc/nginx/preprod_domains.conf;
>     server_name_in_redirect                 off;
>     include                                 common/preprod.conf
> }
>
> Which means (600 x 5 x 2) vhosts...
>
> Is there a better way ?
>
> --
> Greg
>
> _______________________________________________
> 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/20120516/1fe839df/attachment-0001.html>


More information about the nginx mailing list