services: Make it possible to include dynamic modules in nginx.

* gnu/services/web.scm (<nginx-configuration>): Add modules field.
(nginx-configuration-modules): New field accessor.
(emit-load-module): New procedure.
(default-nginx-config): Add support for the modules field.
* doc/guix.texi (NGINX): Document it.
This commit is contained in:
Florian Pelz 2019-11-06 19:15:57 +01:00
parent edc85fd6da
commit 00e680a411
No known key found for this signature in database
GPG key ID: 300888CB39C63817
2 changed files with 19 additions and 0 deletions

View file

@ -19765,6 +19765,17 @@ use the size of the processors cache line.
@item @code{server-names-hash-bucket-max-size} (default: @code{#f})
Maximum bucket size for the server names hash tables.
@item @code{modules} (default: @code{'()})
List of nginx dynamic modules to load. This should be a list of file
names of loadable modules, as in this example:
@lisp
(modules
(list
(file-append nginx-accept-language-module "\
/etc/nginx/modules/ngx_http_accept_language_module.so")))
@end lisp
@item @code{extra-content} (default: @code{""})
Extra content for the @code{http} block. Should be string or a string
valued G-expression.

View file

@ -9,6 +9,7 @@
;;; Copyright © 2018 Pierre-Antoine Rouby <pierre-antoine.rouby@inria.fr>
;;; Copyright © 2017, 2018, 2019 Christopher Baines <mail@cbaines.net>
;;; Copyright © 2018 Marius Bakke <mbakke@fastmail.com>
;;; Copyright © 2019 Florian Pelz <pelzflorian@pelzflorian.de>
;;;
;;; This file is part of GNU Guix.
;;;
@ -95,6 +96,7 @@ (define-module (gnu services web)
nginx-configuration-upstream-blocks
nginx-configuration-server-names-hash-bucket-size
nginx-configuration-server-names-hash-bucket-max-size
nginx-configuration-modules
nginx-configuration-extra-content
nginx-configuration-file
@ -522,6 +524,7 @@ (define-record-type* <nginx-configuration>
(default #f))
(server-names-hash-bucket-max-size nginx-configuration-server-names-hash-bucket-max-size
(default #f))
(modules nginx-configuration-modules (default '()))
(extra-content nginx-configuration-extra-content
(default ""))
(file nginx-configuration-file ;#f | string | file-like
@ -542,6 +545,9 @@ (define (config-index-strings names)
((? string? str) (list str " ")))
names))
(define (emit-load-module module)
(list "load_module " module ";\n"))
(define emit-nginx-location-config
(match-lambda
(($ <nginx-location-configuration> uri body)
@ -615,12 +621,14 @@ (define (default-nginx-config config)
server-blocks upstream-blocks
server-names-hash-bucket-size
server-names-hash-bucket-max-size
modules
extra-content)
(apply mixed-text-file "nginx.conf"
(flatten
"user nginx nginx;\n"
"pid " run-directory "/pid;\n"
"error_log " log-directory "/error.log info;\n"
(map emit-load-module modules)
"http {\n"
" client_body_temp_path " run-directory "/client_body_temp;\n"
" proxy_temp_path " run-directory "/proxy_temp;\n"