Hi, Julien Lepiller <jul...@lepiller.eu> skribis:
> On Wed, 19 Oct 2016 23:04:14 +0200 > l...@gnu.org (Ludovic Courtès) wrote: > >> Hi Julien, >> >> This looks like a great improvement to me! Sounds nicer than fiddling >> with config files. >> >> I suppose we could make ‘nginx-service-type’ extensible (info "(guix) >> Service Types and Services") so that people can write services that >> define new vhosts? > > You mean something like udev-service-type where you could extend it > with a list of vhosts? Yes, exactly. So for example one could write a service for some high-level Web service that would in turn create an nginx vhost. WDYT? > From 8bda6fdd53b3cc7470fac67228a88e0d165134dd Mon Sep 17 00:00:00 2001 > From: Julien Lepiller <jul...@lepiller.eu> > Date: Mon, 26 Sep 2016 23:55:58 +0200 > Subject: [PATCH] services: improve nginx-service configuration > > * gnu/services/web.scm (<nginx-vhost-configuration>): New record type. > (config-domain-strings): New procedure. > (config-index-strings): New procedure. > (default-nginx-vhost-config): New procedure. > (default-nginx-config): Add vhost support and temporary directories > (nginx-activation): Create temporary directories > (nginx-service): Add vhost-list key. > * doc/guix.texi (Web Services): Document 'nginx-vhost-configuration'. Applied with the minor changes below. Thank you! Ludo’.
diff --git a/doc/guix.texi b/doc/guix.texi index 646808b..1293b8b 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -27,7 +27,8 @@ Copyright @copyright{} 2016 Chris Marusich@* Copyright @copyright{} 2016 Efraim Flashner@* Copyright @copyright{} 2016 John Darrington@* Copyright @copyright{} 2016 ng0@* -Copyright @copyright{} 2016 Jan Nieuwenhuizen +Copyright @copyright{} 2016 Jan Nieuwenhuizen@* +Copyright @copyright{} 2016 Julien Lepiller Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -10417,6 +10418,7 @@ this to work, use the default value for @var{config-file}. @deftp {Data Type} nginx-vhost-configuration Data type representing the configuration of an nginx virtual host. This type has the following parameters: + @table @asis @item @code{http-port} (default: @code{80}) Nginx will listen for HTTP connection on this port. Set it at @code{#f} if @@ -10434,18 +10436,18 @@ Note that nginx can listen for HTTP and HTTPS connections in the same A list of server names this vhost represents. @code{'default} represents the default vhost for connections matching no other vhost. -@item @code{root} (default: @code{``/srv/http''}) +@item @code{root} (default: @code{"/srv/http"}) Root of the website nginx will serve. -@item @code{index} (default: @code{(list ``index.html'')}) +@item @code{index} (default: @code{(list "index.html")}) Index files to look for when clients ask for a directory. If it cannot be found, Nginx will send the list of files in the directory. -@item @code{ssl-certificate} (default: @code{``/etc/nginx/cert.pem''}) +@item @code{ssl-certificate} (default: @code{"/etc/nginx/cert.pem"}) Where to find the certificate for secure connections. Set it to @code{#f} if you don't have a certificate or you don't want to use HTTPS. -@item @code{ssl-certificate-key} (default: @code{``/etc/nginx/key.pem''}) +@item @code{ssl-certificate-key} (default: @code{"/etc/nginx/key.pem"}) Where to find the private key for secure connections. Set it to @code{#f} if you don't have a key or you don't want to use HTTPS. diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 49a2962..59e1e54 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -87,7 +87,7 @@ of index files." names))) (define (default-nginx-vhost-config vhost) - (string-append + (string-append " server {\n" (if (nginx-vhost-configuration-http-port vhost) (string-append " listen " @@ -130,9 +130,9 @@ of index files." " scgi_temp_path " run-directory "/scgi_temp;\n" " access_log " log-directory "/access.log;\n" (let ((http (map default-nginx-vhost-config vhost-list))) - (do ((http http (cdr http)) - (block "" (string-append (car http) "\n" block ))) - ((null? http) block))) + (do ((http http (cdr http)) + (block "" (string-append (car http) "\n" block ))) + ((null? http) block))) "}\n" "events {}\n")))