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

Gelonida N gelonida at gmail.com
Wed Nov 23 23:35:42 UTC 2011


On 11/24/2011 12:30 AM, António P. P. Almeida wrote:
> On 23 Nov 2011 23h21 WET, gelonida at gmail.com wrote:
>>>
>>> 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 ?
> 
> 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
> /etc/nginx/sites-available.
> 
> I always name the vhost config files with names that identify it
> explicitly, .e.g, www.example.com.conf. This way there's no risk in
> confusing vhost config with other files that have directives that can
> be used in several vhosts.
> 
Yes combined with your naming style this should be clear enough.
I assume you will just symlink the vhosts file to sites available.
and the include will thus be something like
include ../sites-available/common_settings.conf, right?




More information about the nginx mailing list