Config file templating
René Neumann
lists at necoro.eu
Fri Apr 26 09:50:23 UTC 2013
Hi,
I'm in the mid of converting from lighttpd to nginx. There I have one
small config snippet for each 'subsite' (it's personal only, so lots of
different unrelated stuff). Unfortunately, quite often a snippet
contains a location part that should go into the main server block and
one server block. With nginx, this is not possible as-is.
Example -- file "sites/foo":
----------------------8<---------------------
location /foo {
# do something
}
server {
include "listen";
server_name foo.example.com
return 301 http://example.com/foo$request_uri
}
---------------------->8---------------------
Does anyone have a working solution (probably some template approach)
which would allow to include the snippets in two places and ignoring
'the wrong part'? So that it might look like:
nginx.conf:
----------------------8<---------------------
# ...
server {
include "listen";
server_name example.com;
include "snippets/*";
}
include "snippets/*";
---------------------->8---------------------
sites/foo:
-----------------------8<--------------------
# if server
location /foo {
# do something
}
# endif
# if main
server {
include "listen";
server_name foo.example.com
return 301 http://example.com/foo$request_uri
}
# endif
---------------------->8---------------------
Thanks,
René
More information about the nginx
mailing list