# Default Nginx Client_max_body_size

The default value for the `client_max_body_size` directive in Nginx is **1 megabyte (1M)**. This setting controls the maximum size of the client request body, which includes file uploads and POST data.

If a client tries to upload a file or send data that exceeds this limit, Nginx will return a `413 Request Entity Too Large` error.

### **How to Check or Modify the Default Value**

To check or modify this value, follow these steps:

### **1. Check Current Configuration**

You can check the current `client_max_body_size` value by looking at your Nginx configuration files. If it’s not explicitly set, it will default to 1MB.

**Find the Configuration File:**

Common locations for the Nginx configuration file are:

- `/etc/nginx/nginx.conf`
- `/etc/nginx/conf.d/`
- `/etc/nginx/sites-available/`

**Command to Find Configuration:**

```bash
grep client_max_body_size /etc/nginx/nginx.conf /etc/nginx/conf.d/* /etc/nginx/sites-available/*
```

**Explanation:**

- This command searches for the `client_max_body_size` directive across common Nginx configuration files.

### **2. Modify `client_max_body_size`**

To change the maximum allowed body size, edit the Nginx configuration file and set the `client_max_body_size` directive to your desired value.

**Edit Configuration File:**

Open the Nginx configuration file in a text editor:

```bash
sudo nano /etc/nginx/nginx.conf
```

**Add or Modify `client_max_body_size`:**

Add or update the directive within the `http` block or in a specific `server` block.

**Example Configuration:**

```
http {
    # Other configurations...

    client_max_body_size 10M;  # Increase limit to 10MB

    # Other configurations...
}
```

**Or within a specific `server` block:**

```
server {
    listen 80;
    server_name your-domain.com;

    root /var/www/html;
    index index.html;

    client_max_body_size 10M;  # Increase limit to 10MB

    location / {
        try_files $uri $uri/ =404;
    }
}
```

### **3. Test the Configuration**

After making changes, test the configuration to ensure there are no syntax errors:

```bash
sudo nginx -t
```

**Explanation:**

- This command checks the syntax of the Nginx configuration files.

### **4. Reload or Restart Nginx**

Apply the changes by reloading or restarting Nginx:

**Reload Command:**

```bash
sudo systemctl reload nginx
```

**Or restart (if necessary):**

```bash
sudo systemctl restart nginx
```

### **Summary**

- **Default Value:** The default `client_max_body_size` in Nginx is 1M (1 megabyte).
- **Modify Value:** Edit the `nginx.conf` file or appropriate configuration file and set the `client_max_body_size` directive to your desired limit.
- **Test and Apply:** Use `nginx -t` to test the configuration and `systemctl reload nginx` to apply the changes.

Adjusting this directive allows you to control the maximum size of client request bodies and can help prevent issues with file uploads and large POST requests.