Nginx PUT requests failing to reach PHP-FPM API backend

Problem

I have set up an Nginx reverse proxy for my PHP API, with CORS headers configured. While GET and POST requests work fine, PUT requests are failing to reach my PHP backend, even though the API endpoints are configured to handle PUT requests.

Configuration

Here’s my current Nginx configuration:

server {
    listen 80;
    server_name _;
    root /var/www/api;
    index index.php;

    location / {
        # CORS headers
        add_header 'Access-Control-Allow-Origin' '*' always;
        add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, PATCH, OPTIONS' always;
        add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always;
        add_header 'Access-Control-Max-Age' '3600' always;

        # Handle OPTIONS method
        if ($request_method = 'OPTIONS') {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, PATCH, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization';
            add_header 'Access-Control-Max-Age' '3600';
            add_header 'Content-Type' 'text/plain; charset=utf-8';
            add_header 'Content-Length' 0;
            return 204;
        }

        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ .php$ {
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_pass api-php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

What I’ve Tried

  1. CORS headers are properly set up and OPTIONS preflight requests are being handled
  2. The PHP API endpoints are configured to accept PUT requests
  3. GET and POST requests work correctly through the same setup

Expected Behavior

PUT requests should be passed through to the PHP backend and processed by the API endpoints.

Actual Behavior

PUT requests are not reaching the PHP backend: "PUT /users?id=10 HTTP/1.1" 405 157 "-" "-" "-"

Question

What configuration changes are needed to allow PUT requests to properly reach the PHP backend through Nginx?