phpnginxlockedlocked-files

How to configure nginx to use a lock file to generate a 423 Locked response?


Environment :

I am using nginx 1.14.2 and php-fpm 7.2 (nginx and php-fpm are on the same VM)

Context : I developed the following use case : when a lock file is present on the filesystem (created/deleted by an "upgrade" script), I return a 423 Locked HTTP response via my source code. (the script is used to update some files and clear the cache of the server)

Issue : I want nginx to handle the lock file to return the 423 Locked response and "free" the php-fpm process.

Is it possible to configure nginx for a such behavior ?


Solution

  •    if (-f /path/to/file) {
            return 423;
        }