# Configuration Files Structure

## 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&#x20;

* 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://strangebutohwell.gitbook.io/knowledge/linux/applications/nginx/configuration-files.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
