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

António P. P. Almeida appa at
Wed Nov 23 22:51:10 UTC 2011

On 23 Nov 2011 22h23 WET, gelonida at wrote:

> Hi,
> I'm still a little shaky with how to best structure my nginx
> configurations and where one can / should use includes and where one
> couldn't.
> 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
> Of course both would need their own certificate and host name.
> 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:

You can try this script for enabling each site and disabling using the
sites_enabled/sites-available layout.

--- appa

More information about the nginx mailing list