📓
Knowledge
  • Knowledge Base
  • Applications
    • Gitbook
      • CSS Overrides
    • PiHole
      • Automated Whitelist Script
      • Block Lists
      • Config Files
      • DNS over HTTPS
      • Local DNS
    • SSH
      • SCP
      • SSH Keys
        • ssh-add
        • ssh-agent
        • ssh-keygen
      • SSH on Windows
      • SSH on macOS
    • Youtube-DL
      • Youtube-DL Config File
      • Youtube-DL .netrc File
  • Linux
    • Administration
      • dmesg
      • Unattended Upgrades
      • cron
        • cron.d Directory
        • Listing cron jobs
      • sudo
        • BUG: setrlimit(RLIMIT_CORE) Error
        • Add Sudo Privileges to User
      • System Restart Required
    • Applications
      • Apache
      • ddclient
        • Installing Latest (ddclient)
        • Cloudflare DNS (ddclient)
        • Commands (ddclient)
      • PHP
      • NGINX
        • Configuration Files Structure
    • Commands
      • ln -s : Symbolic Links
      • rsync
    • File System
      • File Management
        • Extended Attributes
        • find (command)
        • rsync (command)
        • tar (command)
      • File Sharing
        • AFP
        • SAMBA
        • NFS
      • Volume Management
      • ZFS on Linux
        • Reference Guides
        • Installing ZFS on Debian
        • Migrating ZFS Pools
        • sharenfs - Native ZFS NFS shares
    • Hardware
    • Networking
      • Disable IPv6
    • New System Setup
      • Debian Setup Guides
      • Disable CloudInit (Ubuntu)
      • Recommended packages
    • Package Management
      • apt Commands
      • apt Logs & History
      • Getting info about Packages
      • dpkg
      • dpkg-query
    • Performance & Diagnostics
      • Memory Usage
      • SMART Drive Tools
      • System Information
    • Remote Desktop
    • SystemD
      • Delay Docker until after ZFS init
      • Documentation for SystemD
      • Show Service's Connections
    • Users & Groups
      • Adding New Users
  • Shells
    • Change Default Shell
      • macOS
    • Get Shell Information
    • Screen
    • Terminal Emulators
      • iTerm2
    • zsh
      • macOS Config
  • macOS
    • Hostname - macOS
    • Homebrew
      • Formulae (packages)
        • speedtest-cli
  • BASH
    • Check if File / Directory Exists
  • Docker
    • Docker Networking
    • Install Docker
      • Enable Memory Swappiness - Linux
    • Docker Compose
      • Environmental Variables for Compose
    • Docker Networking
    • Docker Commands
      • docker attach
  • Python
    • Virtual Environments
  • Web Services
    • DNS Records
      • DNS SPF Record
      • WHOIS - Lookup
    • Domain Parking
    • IANA Registered Ports & Services
Powered by GitBook
On this page
  • Nginx Configuration File’s Structure and Best Practices
  • Sites
  • Log Files
  • Webroot
  • Snippets
  1. Linux
  2. Applications
  3. NGINX

Configuration Files Structure

Nginx Configuration Files

Nginx Configuration File’s Structure and Best Practices

  • All Nginx configuration files are located in the /etc/nginx directory.

  • The main Nginx configuration file is /etc/nginx/nginx.conf

Sites

  • To make Nginx configuration easier to maintain, it is recommended to create a separate configuration file for each domain. You can have as many server block files as you need.

  • Nginx server block files are stored in /etc/nginx/sites-available directory. The configuration files found in this directory are not used by Nginx unless they are linked to the /etc/nginx/sites-enabled directory.

  • To activate a server block, you need to create a symlink (a pointer) from the configuration file sites in a sites-available directory to the sites-enabled directory.

  • It is recommended to follow the standard naming convention. For example, if your domain name is mydomain.com then your configuration file should be named /etc/nginx/sites-available/mydomain.com.conf

Log Files

  • Nginx log files (access.log and error.log) are located in the /var/log/nginx directory. It is recommended to have a different access and error log files for each server block.

Webroot

  • You can set your domain document root directory to any location you want. The most common locations for webroot include:

    • /home/<user_name>/<site_name>

    • /var/www/<site_name>

    • /var/www/html/<site_name>

    • /opt/<site_name>

Snippets

  • The /etc/nginx/snippets directory contains configuration snippets that can be included in the server block files. If you use repeatable configuration segments, then you can refactor those segments into snippets and include the snippet file to the server blocks.

PreviousNGINXNextCommands

Last updated 4 years ago