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

Gelonida N gelonida at gmail.com
Wed Nov 23 23:21:09 UTC 2011


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 gmail.com 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 server_1.mysite.net
>> the other server_2.mysite.net:4433
>>
. . .
>>
>> 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:
> 
> server_1.mysite.net.conf
> server_2.mysite.net.conf

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 ?


> 
> You can try this script for enabling each site and disabling using the
> sites_enabled/sites-available layout.
> 
> https://github.com/perusio/nginx_ensite

That looks nice :-) WIll try it.





More information about the nginx mailing list