LinuxCommandLibrary

nginx

Serve web content and reverse proxy

TLDR

Start server with the default configuration file

$ nginx
copy

Start server with a custom configuration file
$ nginx -c [configuration_file]
copy

Start server with a prefix for all relative paths in the configuration file
$ nginx -c [configuration_file] -p [prefix/for/relative/paths]
copy

Test the configuration without affecting the running server
$ nginx -t
copy

Reload the configuration by sending a signal with no downtime
$ nginx -s reload
copy

SYNOPSIS

nginx [-?hvVtTqg file] [-s signal] [-c file] [-p prefix] [-e file]

PARAMETERS

-?
    -?: Show help message.

-h
    -h: Same as -?, show help message.

-v
    -v: Show version information.

-V
    -V: Show version and configure options.

-t
    -t: Test the configuration file syntax.

-T
    -T: Test the configuration file syntax and dump it.

-q
    -q: Suppress non-error messages during configuration testing.

-s signal
    -s signal: Send a signal to the master process. Signals can be stop, reload, reopen, or quit.

-c file
    -c file: Use an alternate configuration file instead of the default.

-p prefix
    -p prefix: Set the prefix path for configuration files and other relative paths.

-e file
    -e file: Use an alternate error log file.

-g file
    -g file: Set global directives out of the configuration file.

DESCRIPTION

nginx (pronounced "engine-x") is a high-performance HTTP server, reverse proxy, and IMAP/POP3 proxy server. It is known for its stability, rich feature set, simple configuration, and low resource consumption.

It's designed to handle a large number of concurrent connections efficiently. Nginx employs an event-driven, asynchronous, non-blocking architecture, which makes it well-suited for serving static content, load balancing, and acting as a reverse proxy in front of application servers like Apache, Gunicorn, or Node.js.

Nginx's configuration is typically managed through a single configuration file, often located at `/etc/nginx/nginx.conf`, and/or files in `/etc/nginx/conf.d/`. These files define how Nginx handles incoming requests, maps them to specific content, and interacts with backend servers.

Because of its speed, scalability and wide availability, it is one of the most popular webservers on the internet.

CAVEATS

Nginx requires root privileges to bind to ports below 1024 by default. The configuration file syntax can be complex and requires careful attention to detail.

SIGNALS

stop: Immediately stops the server.
reload: Reloads the configuration file without downtime.
reopen: Reopens log files.
quit: Gracefully shuts down the server, allowing existing connections to complete.

HISTORY

Nginx was first publicly released in 2004 by Igor Sysoev. It was initially created to solve the C10K problem, a challenge of handling 10,000 concurrent connections on a single server. Over time, it has gained widespread adoption due to its performance and flexibility, becoming one of the leading web servers globally.

SEE ALSO

Copied to clipboard