nginx.conf is a configuration file used by the Nginx web server.

nginx.conf contains all the configuration of a Nginx web server in a text-based configuration file.

Default location

The default location of nginx.conf is /etc/nginx/nginx.conf.

However, different Linux distributions and other operating systems may place the configuration file in different locations:

  • /usr/local/nginx/conf/nginx.conf
  • /usr/local/etc/nginx/nginx.conf


A nginx.conf file uses key-value pairs called "directives". These can be simple directives (name and parameter separated by space and ending with a semicolon ;) or block directives (multiple directives group together using curly braces { }).

Simple Directive

An example of an nginx.conf simple directive:

user             www;

Blocks Directives

An examples of a nginx.conf block directive:

server {
    listen              80;

    location / {

Another example of a block:

events {
    worker_connections  4096; ## Example of comment