Nginx

Updated: September 28, 2024

Commands for controlling nginx server.

Nginx has more info on multiple needs.
Especially generating custom configurations.


Table of Contents

tldr

# test with custom config while setting 2 workers
nginx -t -c ~/mynginx.conf -g "pid /var/run/nginx.pid; worker_processes 2;"

# graceful shutdown master process with <SIGNAL>
nginx -QUIT $( cat /usr/local/nginx/logs/nginx.pid )

ARGUMENTS

nginx
  -?, -h            # print help
  -v                # print version
  -t                # test config file without running
  -q                # supress non error messages
  -s <SIGNAL>       # send signal to a master process
  -p <path>         # set prefix path | default /usr/local/nginx
  -c <file>         # specify a config file to use instead of default
  -g <directives>   # set global directives
  -V                # print nginx and compiler version | configure params

SIGNALS

TERM, INT       # quick shutdown
QUIT            # graceful shutdown
KILL            # halt a stubborn process
HUP             # reload config with new process and shutdown old workers
USR1            # reopen the log files
USR2            # upgrade executable on the fly
WINCH           # gracefully shutdown the worker process

GZIP

gzip on;
gzip_vary on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;