Quantcast
Channel: Nginx Forum - Nginx Mailing List - English
Viewing all articles
Browse latest Browse all 7229

Config file templating (no replies)

$
0
0
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

Viewing all articles
Browse latest Browse all 7229

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>