Feb 22, 2021

11 min read

Nginx Basics – Part 0: Configuration Files

Written by

Vippy The VPS

Nginx is one the most useful pieces of software when it comes to the web. It has quickly grown from a simple web server to a fully-featured load balancer, reverse proxy server, and a key component in technologies like Kubernetes as an ingress point. Developers, DevOps and sysadmins all come across its installations in some capacity or the other. So let's dig into what are the various nuts and bolts of a typical Nginx installation. We will focus only on the essential parts of configurations -- The Basics.


A. For Debian and Ubuntu like systems the main configuration files can be found at:

  • /etc/nginx/nginx.conf  where all the main configuration lives. You need not edit this.
  • Directory /etc/nginx/sites-enabled/ with a default file already there for reference

Any custom configuration you wish to add can be added in the directory /etc/nginx/sites-available and you can then create a symlink of that file to the directory /etc/nginx/sites-enabled:

$ sudo ln -s /etc/nginx/sites-available/my-configuration.conf /etc/nginx/sites-enabled
$ sudo systemctl reload nginx

That's the Debian way of doing things. You can also add configurations to /etc/nginx/conf.d/

B. On CentOS, Fedora and RedHat systems:

  • All the default configuration is crammed inside /etc/nginx/nginx.conf
  • For most use cases, the custom configuration will go to /etc/nginx/conf.d with file names ending in .conf 


To get started you will need the following:

  1. Root access to a VPS with a Public IPv4 address. If you don't already have one, you can get one from SSDNodes.
  2. Ubuntu 20.04 LTS is used as the base operating system. Although, we will discuss the difference between Nginx on different distributions too.

The Default Nginx Setup

Let's install, enable and start Nginx:

$ sudo apt install nginx -y;
$ sudo systemctl enable --now nginx;

By default Nginx will start a simple HTTP server, and serve this default web page:

Nginx Default Webpage

You can view the webpage, by simply typing in the Public IP address of your VPS  in a web browser. The actual webpage might be different for RedHat like distros and Ubuntu, but ultimately it will be a simple html file that Nginx is configured to serve. Which brings us to the next part -- Configuration.

Configuration Files

All the configuration for Nginx lives in the directory /etc/nginx with the /etc/nginx/nginx.conf file at the heart. This is where things get interesting.

Continue reading this article
by subscribing to our newsletter.
Subscribe now

A note about tutorials: We encourage our users to try out tutorials, but they aren't fully supported by our team—we can't always provide support when things go wrong. Be sure to check which OS and version it was tested with before you proceed.

If you want a fully managed experience, with dedicated support for any application you might want to run, contact us for more information.

Leave a Reply