(gnu services web) module provides the following service:
Return a service that runs nginx, the nginx web server.
The nginx daemon loads its runtime configuration from config-file. Log files are written to log-directory and temporary runtime data files are written to run-directory. For proper operation, these arguments should match what is in config-file to ensure that the directories are created when the service is activated.
As an alternative to using a config-file, server-list can be used to specify the list of server blocks required on the host and upstream-list can be used to specify a list of upstream blocks to configure. For this to work, use the default value for config-file.
nginx has not yet read its configuration file, so it
uses a default file to log error messages. If it fails to load its
configuration file, that is where error messages are logged. After the
configuration file is loaded, the default error log file changes as per
configuration. In our case, startup error messages can be found in
/var/run/nginx/logs/error.log, and after configuration in
/var/log/nginx/error.log. The second location can be changed with the
log-directory configuration option.
This is type for the nginx web server.
This service can be extended to add server blocks in addition to the default one, as in this example:
(simple-service 'my-extra-server nginx-service-type (list (nginx-server-configuration (https-port #f) (root "/srv/http/extra-website"))))
Data type representing the configuration of an nginx server block. This type has the following parameters:
Nginx will listen for HTTP connection on this port. Set it at
nginx should not listen for HTTP (non secure) connection for this
Nginx will listen for HTTPS connection on this port. Set it at
nginx should not listen for HTTPS (secure) connection for this server block.
Note that nginx can listen for HTTP and HTTPS connections in the same server block.
A list of server names this server represents.
'default represents the
default server for connections matching no other server.
Root of the website nginx will serve.
A list of nginx-location-configuration or nginx-named-location-configuration records to use within this server block.
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.
Where to find the certificate for secure connections. Set it to
you don’t have a certificate or you don’t want to use HTTPS.
Where to find the private key for secure connections. Set it to
you don’t have a key or you don’t want to use HTTPS.
Whether the server should add its configuration to response.