* [PATCH 1/2] gnu: services: web: Add support for NGinx upstream module
@ 2017-01-14 22:12 Christopher Baines
2017-01-14 22:12 ` [PATCH 2/2] gnu: services: web: Add support for NGinx location blocks Christopher Baines
2017-01-18 8:08 ` [PATCH 1/2] gnu: services: web: Add support for NGinx upstream module Christopher Baines
0 siblings, 2 replies; 8+ messages in thread
From: Christopher Baines @ 2017-01-14 22:12 UTC (permalink / raw)
To: guix-devel
* gnu/services/web.scm (<nginx-upstream-configuration>): New record type.
(<nginx-configuration>): Add new field upstream-blocks.
(nginx-upstream): New function.
(default-nginx-config): Add upstream-list parameter.
(nginx-service): Add optional upstream list keyword argument.
* doc/guix.text (Web Services): Document the new nginx-upstream-configuration
data type and changes to the nginx function.
---
doc/guix.texi | 26 ++++++++++++++++++++++++--
gnu/services/web.scm | 38 ++++++++++++++++++++++++++++++--------
2 files changed, 54 insertions(+), 10 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index fa07aba5a..5603dd893 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12282,6 +12282,7 @@ The @code{(gnu services web)} module provides the following service:
[#:log-directory ``/var/log/nginx''] @
[#:run-directory ``/var/run/nginx''] @
[#:server-list '()] @
+ [#:upstream-list '()] @
[#:config-file @code{#f}]
Return a service that runs @var{nginx}, the nginx web server.
@@ -12293,8 +12294,10 @@ arguments should match what is in @var{config-file} to ensure that the
directories are created when the service is activated.
As an alternative to using a @var{config-file}, @var{server-list} can be
-used to specify the list of @dfn{server blocks} required on the host. For
-this to work, use the default value for @var{config-file}.
+used to specify the list of @dfn{server blocks} required on the host and
+@var{upstream-list} can be used to specify a list of @dfn{upstream
+blocks} to configure. For this to work, use the default value for
+@var{config-file}.
@end deffn
@@ -12354,6 +12357,25 @@ Whether the server should add its configuration to response.
@end table
@end deftp
+@deftp {Data Type} nginx-upstream-configuration
+Data type representing the configuration of an nginx upstream block.
+This type has the following parameters:
+
+@table @asis
+@item @code{name}
+Name for this group of servers.
+
+@item @code{servers}
+Specify the addresses of the servers in the group. The address can be
+specified as a IP address (e.g. @samp{127.0.0.1}), domain name
+(e.g. @samp{backend1.example.com}) or a path to a UNIX socket using the
+prefix @samp{unix:}. For addresses using an IP address or domain name,
+the default port is 80, and a different port can be specified
+explicitly.
+
+@end table
+@end deftp
+
@node Network File System
@subsubsection Network File System
@cindex NFS
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index db895405a..2918c3832 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -33,6 +33,8 @@
nginx-configuration?
nginx-server-configuration
nginx-server-configuration?
+ nginx-upstream-configuration
+ nginx-upstream-configuration?
nginx-service
nginx-service-type))
@@ -62,6 +64,12 @@
(server-tokens? nginx-server-configuration-server-tokens?
(default #f)))
+(define-record-type* <nginx-upstream-configuration>
+ nginx-upstream-configuration make-nginx-upstream-configuration
+ nginx-upstream-configuration?
+ (name nginx-upstream-configuration-name)
+ (servers nginx-upstream-configuration-servers))
+
(define-record-type* <nginx-configuration>
nginx-configuration make-nginx-configuration
nginx-configuration?
@@ -69,6 +77,7 @@
(log-directory nginx-configuration-log-directory) ;string
(run-directory nginx-configuration-run-directory) ;string
(server-blocks nginx-configuration-server-blocks) ;list
+ (upstream-blocks nginx-configuration-upstream-blocks) ;list
(file nginx-configuration-file)) ;string | file-like
(define (config-domain-strings names)
@@ -116,11 +125,18 @@ of index files."
" index " (config-index-strings (nginx-server-configuration-index server)) ";\n"
" server_tokens " (if (nginx-server-configuration-server-tokens? server)
"on" "off") ";\n"
+(define (nginx-upstream-config upstream)
+ (string-append
+ " upstream " (nginx-upstream-configuration-name upstream) " {\n"
+ (apply
+ string-append
+ (map (lambda (server)
+ " server " server ";\n")
+ (nginx-upstream-configuration-servers upstream)))
" }\n"))
-(define (default-nginx-config log-directory run-directory server-list)
- (plain-file "nginx.conf"
- (string-append
+(define (default-nginx-config log-directory run-directory server-list upstream-list)
+ (mixed-text-file "nginx.conf"
"user nginx nginx;\n"
"pid " run-directory "/pid;\n"
"error_log " log-directory "/error.log info;\n"
@@ -131,12 +147,16 @@ of index files."
" uwsgi_temp_path " run-directory "/uwsgi_temp;\n"
" scgi_temp_path " run-directory "/scgi_temp;\n"
" access_log " log-directory "/access.log;\n"
+ (string-join
+ (filter (lambda (section) (not (null? section)))
+ (map nginx-upstream-config upstream-list))
+ "\n")
(let ((http (map default-nginx-server-config server-list)))
(do ((http http (cdr http))
(block "" (string-append (car http) "\n" block )))
((null? http) block)))
"}\n"
- "events {}\n")))
+ "events {}\n"))
(define %nginx-accounts
(list (user-group (name "nginx") (system? #t))
@@ -151,7 +171,7 @@ of index files."
(define nginx-activation
(match-lambda
(($ <nginx-configuration> nginx log-directory run-directory server-blocks
- config-file)
+ upstream-blocks config-file)
#~(begin
(use-modules (guix build utils))
@@ -169,13 +189,13 @@ of index files."
(system* (string-append #$nginx "/sbin/nginx")
"-c" #$(or config-file
(default-nginx-config log-directory
- run-directory server-blocks))
+ run-directory server-blocks upstream-blocks))
"-t")))))
(define nginx-shepherd-service
(match-lambda
(($ <nginx-configuration> nginx log-directory run-directory server-blocks
- config-file)
+ upstream-blocks config-file)
(let* ((nginx-binary (file-append nginx "/sbin/nginx"))
(nginx-action
(lambda args
@@ -184,7 +204,7 @@ of index files."
(system* #$nginx-binary "-c"
#$(or config-file
(default-nginx-config log-directory
- run-directory server-blocks))
+ run-directory server-blocks upstream-blocks))
#$@args))))))
;; TODO: Add 'reload' action.
@@ -216,6 +236,7 @@ of index files."
(log-directory "/var/log/nginx")
(run-directory "/var/run/nginx")
(server-list '())
+ (upstream-list '())
(config-file #f))
"Return a service that runs NGINX, the nginx web server.
@@ -227,4 +248,5 @@ files in LOG-DIRECTORY, and stores temporary runtime files in RUN-DIRECTORY."
(log-directory log-directory)
(run-directory run-directory)
(server-blocks server-list)
+ (upstream-blocks upstream-list)
(file config-file))))
--
2.11.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] gnu: services: web: Add support for NGinx location blocks
2017-01-14 22:12 [PATCH 1/2] gnu: services: web: Add support for NGinx upstream module Christopher Baines
@ 2017-01-14 22:12 ` Christopher Baines
2017-01-18 8:08 ` [PATCH 1/2] gnu: services: web: Add support for NGinx upstream module Christopher Baines
1 sibling, 0 replies; 8+ messages in thread
From: Christopher Baines @ 2017-01-14 22:12 UTC (permalink / raw)
To: guix-devel
* gnu/services/web.scm (<nginx-server-configuration>): Add field locations.
(<nginx-location-configuration>): New record type.
(<nginx-named-location-configuration>): New record type.
(nginx-location-config): New function.
(default-nginx-server-config): Inlcude locations.
* doc/guix.text (Web Services): Document the new nginx-location-configuration
and nginx-named-location-configuration data types, as well as the changes to
the nginx-server-configuration.
---
doc/guix.texi | 43 +++++++++++++++++++++++++++++++++++++++++++
gnu/services/web.scm | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 81 insertions(+)
diff --git a/doc/guix.texi b/doc/guix.texi
index 5603dd893..045dee76c 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12339,6 +12339,11 @@ default server for connections matching no other server.
@item @code{root} (default: @code{"/srv/http"})
Root of the website nginx will serve.
+@item @code{locations} (default: @code{'()})
+A list of @dfn{nginx-location-configuration} or
+@dfn{nginx-named-location-configuration} records to use within this
+server block.
+
@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.
@@ -12376,6 +12381,44 @@ explicitly.
@end table
@end deftp
+@deftp {Data Type} nginx-location-configuration
+Data type representing the configuration of an nginx location block.
+This type has the following parameters:
+
+@table @asis
+@item @code{uri}
+URI which this location block matches.
+
+@anchor{nginx-location-configuration body}
+@item @code{body}
+Body of the location block, specified as a string. This can contain many
+configuration directives. For example, to pass requests to a upstream
+server group defined using an @code{nginx-upstream-configuration} block,
+the following directive would be specified in the body @samp{proxy_pass
+http://upstream-name;}.
+
+@end table
+@end deftp
+
+@deftp {Data Type} nginx-named-location-configuration
+Data type representing the configuration of an nginx named location
+block. Named location blocks are used for request redirection, and not
+used for regular request processing. This type has the following
+parameters:
+
+@table @asis
+@item @code{name}
+Name to identify this location block.
+
+@item @code{body}
+@xref{nginx-location-configuration body}, as the body for named location
+blocks can be used in a similar way to the
+@code{nginx-location-configuration body}. One restriction is that the
+body of a named location block cannot contain location blocks.
+
+@end table
+@end deftp
+
@node Network File System
@subsubsection Network File System
@cindex NFS
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index 2918c3832..8c6921622 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -35,6 +35,10 @@
nginx-server-configuration?
nginx-upstream-configuration
nginx-upstream-configuration?
+ nginx-location-configuration
+ nginx-location-configuration?
+ nginx-named-location-configuration
+ nginx-named-location-configuration?
nginx-service
nginx-service-type))
@@ -55,6 +59,8 @@
(default (list 'default)))
(root nginx-server-configuration-root
(default "/srv/http"))
+ (locations nginx-server-configuration-locations
+ (default '()))
(index nginx-server-configuration-index
(default (list "index.html")))
(ssl-certificate nginx-server-configuration-ssl-certificate
@@ -70,6 +76,20 @@
(name nginx-upstream-configuration-name)
(servers nginx-upstream-configuration-servers))
+(define-record-type* <nginx-location-configuration>
+ nginx-location-configuration make-nginx-location-configuration
+ nginx-location-configuration?
+ (uri nginx-location-configuration-uri
+ (default #f))
+ (body nginx-location-configuration-body))
+
+(define-record-type* <nginx-named-location-configuration>
+ nginx-named-location-configuration make-nginx-named-location-configuration
+ nginx-named-location-configuration?
+ (name nginx-named-location-configuration-name
+ (default #f))
+ (body nginx-named-location-configuration-body))
+
(define-record-type* <nginx-configuration>
nginx-configuration make-nginx-configuration
nginx-configuration?
@@ -97,6 +117,19 @@ of index files."
((? string? str) (string-append str " ")))
names)))
+(define nginx-location-config
+ (match-lambda
+ (($ <nginx-location-configuration> uri body)
+ (string-append
+ " location " uri " {\n"
+ " " (string-join body "\n ")
+ " }\n"))
+ (($ <nginx-named-location-configuration> name body)
+ (string-append
+ " location @" name " {\n"
+ " " (string-join body "\n ")
+ " }\n"))))
+
(define (default-nginx-server-config server)
(string-append
" server {\n"
@@ -125,6 +158,11 @@ of index files."
" index " (config-index-strings (nginx-server-configuration-index server)) ";\n"
" server_tokens " (if (nginx-server-configuration-server-tokens? server)
"on" "off") ";\n"
+ (string-join
+ (map nginx-location-config (nginx-server-configuration-locations server))
+ "\n")
+ " }\n"))
+
(define (nginx-upstream-config upstream)
(string-append
" upstream " (nginx-upstream-configuration-name upstream) " {\n"
--
2.11.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 1/2] gnu: services: web: Add support for NGinx upstream module
2017-01-14 22:12 [PATCH 1/2] gnu: services: web: Add support for NGinx upstream module Christopher Baines
2017-01-14 22:12 ` [PATCH 2/2] gnu: services: web: Add support for NGinx location blocks Christopher Baines
@ 2017-01-18 8:08 ` Christopher Baines
2017-01-18 8:08 ` [PATCH 2/2] gnu: services: web: Add support for NGinx location blocks Christopher Baines
2017-01-19 13:08 ` [PATCH 1/2] gnu: services: web: Add support for NGinx upstream module Ludovic Courtès
1 sibling, 2 replies; 8+ messages in thread
From: Christopher Baines @ 2017-01-18 8:08 UTC (permalink / raw)
To: guix-devel
* gnu/services/web.scm (<nginx-upstream-configuration>): New record type.
(<nginx-configuration>): Add new field upstream-blocks.
(nginx-upstream): New function.
(default-nginx-config): Add upstream-list parameter.
(nginx-service): Add optional upstream list keyword argument.
* doc/guix.text (Web Services): Document the new nginx-upstream-configuration
data type and changes to the nginx function.
---
doc/guix.texi | 26 ++++++++++++++++++++++++--
gnu/services/web.scm | 40 ++++++++++++++++++++++++++++++++--------
2 files changed, 56 insertions(+), 10 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index fa07aba5a..5603dd893 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12282,6 +12282,7 @@ The @code{(gnu services web)} module provides the following service:
[#:log-directory ``/var/log/nginx''] @
[#:run-directory ``/var/run/nginx''] @
[#:server-list '()] @
+ [#:upstream-list '()] @
[#:config-file @code{#f}]
Return a service that runs @var{nginx}, the nginx web server.
@@ -12293,8 +12294,10 @@ arguments should match what is in @var{config-file} to ensure that the
directories are created when the service is activated.
As an alternative to using a @var{config-file}, @var{server-list} can be
-used to specify the list of @dfn{server blocks} required on the host. For
-this to work, use the default value for @var{config-file}.
+used to specify the list of @dfn{server blocks} required on the host and
+@var{upstream-list} can be used to specify a list of @dfn{upstream
+blocks} to configure. For this to work, use the default value for
+@var{config-file}.
@end deffn
@@ -12354,6 +12357,25 @@ Whether the server should add its configuration to response.
@end table
@end deftp
+@deftp {Data Type} nginx-upstream-configuration
+Data type representing the configuration of an nginx upstream block.
+This type has the following parameters:
+
+@table @asis
+@item @code{name}
+Name for this group of servers.
+
+@item @code{servers}
+Specify the addresses of the servers in the group. The address can be
+specified as a IP address (e.g. @samp{127.0.0.1}), domain name
+(e.g. @samp{backend1.example.com}) or a path to a UNIX socket using the
+prefix @samp{unix:}. For addresses using an IP address or domain name,
+the default port is 80, and a different port can be specified
+explicitly.
+
+@end table
+@end deftp
+
@node Network File System
@subsubsection Network File System
@cindex NFS
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index db895405a..d0ccd02e4 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -33,6 +33,8 @@
nginx-configuration?
nginx-server-configuration
nginx-server-configuration?
+ nginx-upstream-configuration
+ nginx-upstream-configuration?
nginx-service
nginx-service-type))
@@ -62,6 +64,12 @@
(server-tokens? nginx-server-configuration-server-tokens?
(default #f)))
+(define-record-type* <nginx-upstream-configuration>
+ nginx-upstream-configuration make-nginx-upstream-configuration
+ nginx-upstream-configuration?
+ (name nginx-upstream-configuration-name)
+ (servers nginx-upstream-configuration-servers))
+
(define-record-type* <nginx-configuration>
nginx-configuration make-nginx-configuration
nginx-configuration?
@@ -69,6 +77,7 @@
(log-directory nginx-configuration-log-directory) ;string
(run-directory nginx-configuration-run-directory) ;string
(server-blocks nginx-configuration-server-blocks) ;list
+ (upstream-blocks nginx-configuration-upstream-blocks) ;list
(file nginx-configuration-file)) ;string | file-like
(define (config-domain-strings names)
@@ -116,11 +125,18 @@ of index files."
" index " (config-index-strings (nginx-server-configuration-index server)) ";\n"
" server_tokens " (if (nginx-server-configuration-server-tokens? server)
"on" "off") ";\n"
+(define (nginx-upstream-config upstream)
+ (string-append
+ " upstream " (nginx-upstream-configuration-name upstream) " {\n"
+ (apply
+ string-append
+ (map (lambda (server)
+ (simple-format #f " server ~A;\n" server))
+ (nginx-upstream-configuration-servers upstream)))
" }\n"))
-(define (default-nginx-config log-directory run-directory server-list)
- (plain-file "nginx.conf"
- (string-append
+(define (default-nginx-config log-directory run-directory server-list upstream-list)
+ (mixed-text-file "nginx.conf"
"user nginx nginx;\n"
"pid " run-directory "/pid;\n"
"error_log " log-directory "/error.log info;\n"
@@ -131,12 +147,18 @@ of index files."
" uwsgi_temp_path " run-directory "/uwsgi_temp;\n"
" scgi_temp_path " run-directory "/scgi_temp;\n"
" access_log " log-directory "/access.log;\n"
+ "\n"
+ (string-join
+ (filter (lambda (section) (not (null? section)))
+ (map nginx-upstream-config upstream-list))
+ "\n")
+ "\n"
(let ((http (map default-nginx-server-config server-list)))
(do ((http http (cdr http))
(block "" (string-append (car http) "\n" block )))
((null? http) block)))
"}\n"
- "events {}\n")))
+ "events {}\n"))
(define %nginx-accounts
(list (user-group (name "nginx") (system? #t))
@@ -151,7 +173,7 @@ of index files."
(define nginx-activation
(match-lambda
(($ <nginx-configuration> nginx log-directory run-directory server-blocks
- config-file)
+ upstream-blocks config-file)
#~(begin
(use-modules (guix build utils))
@@ -169,13 +191,13 @@ of index files."
(system* (string-append #$nginx "/sbin/nginx")
"-c" #$(or config-file
(default-nginx-config log-directory
- run-directory server-blocks))
+ run-directory server-blocks upstream-blocks))
"-t")))))
(define nginx-shepherd-service
(match-lambda
(($ <nginx-configuration> nginx log-directory run-directory server-blocks
- config-file)
+ upstream-blocks config-file)
(let* ((nginx-binary (file-append nginx "/sbin/nginx"))
(nginx-action
(lambda args
@@ -184,7 +206,7 @@ of index files."
(system* #$nginx-binary "-c"
#$(or config-file
(default-nginx-config log-directory
- run-directory server-blocks))
+ run-directory server-blocks upstream-blocks))
#$@args))))))
;; TODO: Add 'reload' action.
@@ -216,6 +238,7 @@ of index files."
(log-directory "/var/log/nginx")
(run-directory "/var/run/nginx")
(server-list '())
+ (upstream-list '())
(config-file #f))
"Return a service that runs NGINX, the nginx web server.
@@ -227,4 +250,5 @@ files in LOG-DIRECTORY, and stores temporary runtime files in RUN-DIRECTORY."
(log-directory log-directory)
(run-directory run-directory)
(server-blocks server-list)
+ (upstream-blocks upstream-list)
(file config-file))))
--
2.11.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] gnu: services: web: Add support for NGinx location blocks
2017-01-18 8:08 ` [PATCH 1/2] gnu: services: web: Add support for NGinx upstream module Christopher Baines
@ 2017-01-18 8:08 ` Christopher Baines
2017-01-19 13:19 ` Ludovic Courtès
2017-01-19 13:48 ` New nginx test! Ludovic Courtès
2017-01-19 13:08 ` [PATCH 1/2] gnu: services: web: Add support for NGinx upstream module Ludovic Courtès
1 sibling, 2 replies; 8+ messages in thread
From: Christopher Baines @ 2017-01-18 8:08 UTC (permalink / raw)
To: guix-devel
* gnu/services/web.scm (<nginx-server-configuration>): Add field locations.
(<nginx-location-configuration>): New record type.
(<nginx-named-location-configuration>): New record type.
(nginx-location-config): New function.
(default-nginx-server-config): Inlcude locations.
* doc/guix.text (Web Services): Document the new nginx-location-configuration
and nginx-named-location-configuration data types, as well as the changes to
the nginx-server-configuration.
---
doc/guix.texi | 43 +++++++++++++++++++++++++++++++++++++++++++
gnu/services/web.scm | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+)
diff --git a/doc/guix.texi b/doc/guix.texi
index 5603dd893..045dee76c 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12339,6 +12339,11 @@ default server for connections matching no other server.
@item @code{root} (default: @code{"/srv/http"})
Root of the website nginx will serve.
+@item @code{locations} (default: @code{'()})
+A list of @dfn{nginx-location-configuration} or
+@dfn{nginx-named-location-configuration} records to use within this
+server block.
+
@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.
@@ -12376,6 +12381,44 @@ explicitly.
@end table
@end deftp
+@deftp {Data Type} nginx-location-configuration
+Data type representing the configuration of an nginx location block.
+This type has the following parameters:
+
+@table @asis
+@item @code{uri}
+URI which this location block matches.
+
+@anchor{nginx-location-configuration body}
+@item @code{body}
+Body of the location block, specified as a string. This can contain many
+configuration directives. For example, to pass requests to a upstream
+server group defined using an @code{nginx-upstream-configuration} block,
+the following directive would be specified in the body @samp{proxy_pass
+http://upstream-name;}.
+
+@end table
+@end deftp
+
+@deftp {Data Type} nginx-named-location-configuration
+Data type representing the configuration of an nginx named location
+block. Named location blocks are used for request redirection, and not
+used for regular request processing. This type has the following
+parameters:
+
+@table @asis
+@item @code{name}
+Name to identify this location block.
+
+@item @code{body}
+@xref{nginx-location-configuration body}, as the body for named location
+blocks can be used in a similar way to the
+@code{nginx-location-configuration body}. One restriction is that the
+body of a named location block cannot contain location blocks.
+
+@end table
+@end deftp
+
@node Network File System
@subsubsection Network File System
@cindex NFS
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index d0ccd02e4..73ecf77fc 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -35,6 +35,10 @@
nginx-server-configuration?
nginx-upstream-configuration
nginx-upstream-configuration?
+ nginx-location-configuration
+ nginx-location-configuration?
+ nginx-named-location-configuration
+ nginx-named-location-configuration?
nginx-service
nginx-service-type))
@@ -55,6 +59,8 @@
(default (list 'default)))
(root nginx-server-configuration-root
(default "/srv/http"))
+ (locations nginx-server-configuration-locations
+ (default '()))
(index nginx-server-configuration-index
(default (list "index.html")))
(ssl-certificate nginx-server-configuration-ssl-certificate
@@ -70,6 +76,20 @@
(name nginx-upstream-configuration-name)
(servers nginx-upstream-configuration-servers))
+(define-record-type* <nginx-location-configuration>
+ nginx-location-configuration make-nginx-location-configuration
+ nginx-location-configuration?
+ (uri nginx-location-configuration-uri
+ (default #f))
+ (body nginx-location-configuration-body))
+
+(define-record-type* <nginx-named-location-configuration>
+ nginx-named-location-configuration make-nginx-named-location-configuration
+ nginx-named-location-configuration?
+ (name nginx-named-location-configuration-name
+ (default #f))
+ (body nginx-named-location-configuration-body))
+
(define-record-type* <nginx-configuration>
nginx-configuration make-nginx-configuration
nginx-configuration?
@@ -97,6 +117,19 @@ of index files."
((? string? str) (string-append str " ")))
names)))
+(define nginx-location-config
+ (match-lambda
+ (($ <nginx-location-configuration> uri body)
+ (string-append
+ " location " uri " {\n"
+ " " (string-join body "\n ") "\n"
+ " }\n"))
+ (($ <nginx-named-location-configuration> name body)
+ (string-append
+ " location @" name " {\n"
+ " " (string-join body "\n ") "\n"
+ " }\n"))))
+
(define (default-nginx-server-config server)
(string-append
" server {\n"
@@ -125,6 +158,12 @@ of index files."
" index " (config-index-strings (nginx-server-configuration-index server)) ";\n"
" server_tokens " (if (nginx-server-configuration-server-tokens? server)
"on" "off") ";\n"
+ "\n"
+ (string-join
+ (map nginx-location-config (nginx-server-configuration-locations server))
+ "\n")
+ " }\n"))
+
(define (nginx-upstream-config upstream)
(string-append
" upstream " (nginx-upstream-configuration-name upstream) " {\n"
--
2.11.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] gnu: services: web: Add support for NGinx upstream module
2017-01-18 8:08 ` [PATCH 1/2] gnu: services: web: Add support for NGinx upstream module Christopher Baines
2017-01-18 8:08 ` [PATCH 2/2] gnu: services: web: Add support for NGinx location blocks Christopher Baines
@ 2017-01-19 13:08 ` Ludovic Courtès
2017-01-19 20:16 ` Christopher Baines
1 sibling, 1 reply; 8+ messages in thread
From: Ludovic Courtès @ 2017-01-19 13:08 UTC (permalink / raw)
To: Christopher Baines; +Cc: guix-devel
Christopher Baines <mail@cbaines.net> skribis:
> * gnu/services/web.scm (<nginx-upstream-configuration>): New record type.
> (<nginx-configuration>): Add new field upstream-blocks.
> (nginx-upstream): New function.
> (default-nginx-config): Add upstream-list parameter.
> (nginx-service): Add optional upstream list keyword argument.
> * doc/guix.text (Web Services): Document the new nginx-upstream-configuration
> data type and changes to the nginx function.
Applied with minor changes: no “gnu:” in the subject line, and…
> +Data type representing the configuration of an nginx upstream block.
@code{upstream}, to make it clear that this is an nginx config term.
> +prefix @samp{unix:}. For addresses using an IP address or domain name,
^
Two spaces.
> " index " (config-index-strings (nginx-server-configuration-index server)) ";\n"
> " server_tokens " (if (nginx-server-configuration-server-tokens? server)
> "on" "off") ";\n"
> +(define (nginx-upstream-config upstream)
> + (string-append
> + " upstream " (nginx-upstream-configuration-name upstream) " {\n"
> + (apply
> + string-append
> + (map (lambda (server)
> + (simple-format #f " server ~A;\n" server))
> + (nginx-upstream-configuration-servers upstream)))
> " }\n"))
Here there was a syntax error: the last line must also be kept in the
procedure just above the hunk. I guess that was introduced while
rebasing patches or something.
Thanks!
Ludo’.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] gnu: services: web: Add support for NGinx upstream module
2017-01-19 13:08 ` [PATCH 1/2] gnu: services: web: Add support for NGinx upstream module Ludovic Courtès
@ 2017-01-19 20:16 ` Christopher Baines
0 siblings, 0 replies; 8+ messages in thread
From: Christopher Baines @ 2017-01-19 20:16 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
[-- Attachment #1.1: Type: text/plain, Size: 1820 bytes --]
On 19/01/17 13:08, Ludovic Courtès wrote:
> Christopher Baines <mail@cbaines.net> skribis:
>
>> * gnu/services/web.scm (<nginx-upstream-configuration>): New record type.
>> (<nginx-configuration>): Add new field upstream-blocks.
>> (nginx-upstream): New function.
>> (default-nginx-config): Add upstream-list parameter.
>> (nginx-service): Add optional upstream list keyword argument.
>> * doc/guix.text (Web Services): Document the new nginx-upstream-configuration
>> data type and changes to the nginx function.
>
> Applied with minor changes: no “gnu:” in the subject line, and…
>
>> +Data type representing the configuration of an nginx upstream block.
>
> @code{upstream}, to make it clear that this is an nginx config term.
>
>> +prefix @samp{unix:}. For addresses using an IP address or domain name,
> ^
> Two spaces.
>
>> " index " (config-index-strings (nginx-server-configuration-index server)) ";\n"
>> " server_tokens " (if (nginx-server-configuration-server-tokens? server)
>> "on" "off") ";\n"
>> +(define (nginx-upstream-config upstream)
>> + (string-append
>> + " upstream " (nginx-upstream-configuration-name upstream) " {\n"
>> + (apply
>> + string-append
>> + (map (lambda (server)
>> + (simple-format #f " server ~A;\n" server))
>> + (nginx-upstream-configuration-servers upstream)))
>> " }\n"))
>
> Here there was a syntax error: the last line must also be kept in the
> procedure just above the hunk. I guess that was introduced while
> rebasing patches or something.
>
> Thanks!
Great, thanks for applying this. As you say, I think the error in the
first patch was a result in splitting the changes in to two patches.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 858 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-01-19 20:16 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-14 22:12 [PATCH 1/2] gnu: services: web: Add support for NGinx upstream module Christopher Baines
2017-01-14 22:12 ` [PATCH 2/2] gnu: services: web: Add support for NGinx location blocks Christopher Baines
2017-01-18 8:08 ` [PATCH 1/2] gnu: services: web: Add support for NGinx upstream module Christopher Baines
2017-01-18 8:08 ` [PATCH 2/2] gnu: services: web: Add support for NGinx location blocks Christopher Baines
2017-01-19 13:19 ` Ludovic Courtès
2017-01-19 13:48 ` New nginx test! Ludovic Courtès
2017-01-19 13:08 ` [PATCH 1/2] gnu: services: web: Add support for NGinx upstream module Ludovic Courtès
2017-01-19 20:16 ` Christopher Baines
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).