same config for two virtual hosts (except hostname / certificate)

António P. P. Almeida appa at
Wed Nov 23 23:30:03 UTC 2011

On 23 Nov 2011 23h21 WET, gelonida at wrote:

> Thanks for your reply,
> On 11/23/2011 11:51 PM, António P. P. Almeida wrote:
>> On 23 Nov 2011 22h23 WET, gelonida at wrote:
>>> somehow I like the idea of a directory structure like
> . . .
>>> /etc/nginx/ # for basic files / certificates / . . .
>>> /etc/nginx/sites-available # the available configs
>>> /etc/nginx/sites-enabled # the sites, that shall really be started
>>> Now I have two sites (ssl which should share exactly the same
>>> config (except the host name and the server certificate) the first
>>> one would be for example the other
> . . .
>>> What would be the recommended way for such a setup?
>> My suggestion is for you to place the common things in both vhosts
>> in a file, e.g., my_common_config.conf and do an include in each
>> vhost:
> Where would you place my_common_config.conf?
> would you clutter /etc/nginx with it or create a subdir like
> /etf/nginx/sites-baseconfig
> would you then just do an include with a relative path like
> include ../my_common_config.conf ?

I prefer to have it under the sites-available directory. Because is
something specific to one or more of the enabled sites.

There's in Debian a /etc/nginx/conf.d dir but I never use it. I put
all generic stuff in /etc/nginx and site specific stuff under

I always name the vhost config files with names that identify it
explicitly, .e.g, This way there's no risk in
confusing vhost config with other files that have directives that can
be used in several vhosts.

--- appa

More information about the nginx mailing list