server { listen 80; server_name php-constraints.local; root /var/www/nginx/examples/php-constraints; index index.php; location / { try_files $uri $uri/ /index.php?$args; } # Will return 404 Not Found. # location /static-text { # alias index.php; # add_header My-Long-Timeout true always; # include snippets/long_requests.conf; # include snippets/fastcgi-php.conf; # } location ~ \index.php$ { #internal; if ($request_uri ~ (static-text) ) { error_page 419 = @myblock; return 419; # Raises `"include" directive is not allowed here` error. # include snippets/long_requests.conf; # include snippets/fastcgi-php.conf; } include snippets/fastcgi-php.conf; } location @myblock { add_header My-Long-Timeout true always; include snippets/long_requests.conf; include snippets/fastcgi-php.conf; } location @debug { add_header X-debug-message "$uri $args $request_uri" always; default_type application/json; return 200 ' { "request_uri": "$request_uri", "uri": "$uri", "args": "$args", "request_header": "$http_language" } '; } }