Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Moving now from apache to nginx, also rewriting .htaccess to nginx. I have such "problem":

I have about ten sites, that utilize same core.
So I have a bunch of rewrite rules that should go to each of one of them. Moreover, number of sites will be added, as well as number of common rules.

In apache i've used to write all common directives to global /www folder when all websites are placed.

But for now, in nginx i cant determine how should i organize config file.

I have about 10 common rules and 30 per-site rules for every site.

So have no idea, how to NOT to write 10 common rules to each config and in the same time to provide each site with his own rules.

Thanks in advance.

share|improve this question
up vote 1 down vote accepted

You can create a new file in /etc/nginx containing your shared directives, and then include them in each site's configuration.

The config files which ship with nginx include an example of this: fastcgi_params contains shared directives that are used in various configuration files where they call include fastcgi_params;.

share|improve this answer
Thanks This is simple.. By the way, do you know how nginx handles includes? I mean, if there are lot of includes this mean that in memory stored lots of duplicates or I have nothing to worry about? – Tigra Jul 17 '12 at 9:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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