Testing syntax of configuration file
The syntax of the configuration file can be tested like so:
# /usr/sbin/nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Reload config file after modification
After a modification of the configfile, the (running) nginx process can be informed to reload it with
# /usr/sbin/nginx -s reload
Simple example
This is a simple example of an nginx configuration file. It is basically a slightly adapted version of that which I found after installing ningx with sudo apt install -t nginx
.
#
# Specify the user and group by which worker processes are run.
# Because the group is omitted here, it defaults to the name
# of the user.
#
user www-data;
#
# Define the number of worker processes.
# Use the special value «auto» to bind worker processes
# automatically to available CPUs.
#
worker_processes auto;
#
# Specify the file where the main process' ID is stored:
#
pid /run/nginx.pid;
#
# The *.conf files included from /etc/nginx/modules-enabled
# typically contain a load_module statement which
# loads a shared library.
# These shared libraries are usually found in /usr/share/nginx/modules.
#
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
#
# Enable sendfile()
# which is required when enabling tcp_nopush
#
sendfile on;
#
# Set the socket option TCP_CORK (or TCP_NOPUSH in BSD).
# Requires sendfile to be set when enabled.
#
tcp_nopush on;
#
# See this link.
#
# server_names_hash_bucket_size 64;
types_hash_max_size 2048;
# server_tokens off;
# server_name_in_redirect off;
#
# Specify MIME types (default and depending on file suffix)
#
include /etc/nginx/mime.types;
default_type application/octet-stream;
#
# SSL settings
#
# Enable the specified protocols (do not add SSLv3 because of Poodle attack)
#
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
#
# Specify location of log files.
#
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
#
# Enable compression
#
gzip on;
#
# Specify the MIME types which will be compressed.
#
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
gzip_types *;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
#
# Virtual Host Configs
#
include /etc/nginx/conf.d/*.conf;
#
# In a default configuration, the following directive
# causes /etc/nginx/sites-available/default to be
# included because /etc/nginx/sites-available/default is
# a symbolic link to that file.
#
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}