nginx

Installation

On a Debian based system, install one of the nginx-light, nginx-full or nginx-extras packages. See https://wiki.debian.org/Nginx for a list of modules which are included in each of those packages.

Configuration

Test the configuration with:

$ sudo nginx -t

Websockets

Self-signed Certificate

On Debian, install the ssl-cert package:

$ sudo apt-get install ssl-cert

This creates the public and private certifcates in the following locations:

/etc/ssl/certs/ssl-cert-snakeoil.pem;
/etc/ssl/private/ssl-cert-snakeoil.key;

See also LetsEnrypt for notes on creating free certificates using letsencrypt.

Systemd Issue

nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument

Caused by a race condition where systemd attempts to read the PID file before nginx has created it.

$ sudo mkdir /etc/systemd/system/nginx.service.d
$ printf "[Service]\nExecStartPost=/bin/sleep 0.1\n" | sudo tee /etc/systemd/system/nginx.service.d/override.conf
$ sudo systemctl daemon-reload
$ sudo systemctl restart nginx

See https://stackoverflow.com/questions/42078674/nginx-service-failed-to-read-pid-from-file-run-nginx-pid-invalid-argument for more information.

CGI

Resources

-- Frank Dean - 10 Mar 2017

Related Topics NginxOnMacOSX, LetsEncrypt