Next: , Previous: , Up: Services   [Contents][Index]


6.2.7.12 Web Services

The (gnu services web) module provides the following service:

Scheme Procedure: nginx-service [#:nginx nginx] [#: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.

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.

At startup, 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.

Scheme Variable: nginx-service-type

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: nginx-server-configuration

Data type representing the configuration of an nginx server block. This type has the following parameters:

http-port (default: 80)

Nginx will listen for HTTP connection on this port. Set it at #f if nginx should not listen for HTTP (non secure) connection for this server block.

https-port (default: 443)

Nginx will listen for HTTPS connection on this port. Set it at #f if 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.

server-name (default: (list 'default))

A list of server names this server represents. 'default represents the default server for connections matching no other server.

root (default: "/srv/http")

Root of the website nginx will serve.

locations (default: '())

A list of nginx-location-configuration or nginx-named-location-configuration records to use within this server block.

index (default: (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.

ssl-certificate (default: "/etc/nginx/cert.pem")

Where to find the certificate for secure connections. Set it to #f if you don’t have a certificate or you don’t want to use HTTPS.

ssl-certificate-key (default: "/etc/nginx/key.pem")

Where to find the private key for secure connections. Set it to #f if you don’t have a key or you don’t want to use HTTPS.

server-tokens? (default: #f)

Whether the server should add its configuration to response.


Next: , Previous: , Up: Services   [Contents][Index]