Welcome! Log In Create A New Profile

Advanced

Config file templating

René Neumann
April 26, 2013 05:52AM
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é

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Config file templating

René Neumann April 26, 2013 05:52AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 192
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready