What is the purpose of this "location {}" block?

Ben Johnson ben at indietorrent.org
Tue Jul 2 00:28:46 UTC 2013


I'm using ISPConfig3 and the default nginx vhost configuration template
includes the following:

location ~ \.php$ {
    try_files /dcc5f1e779623ed233ada555c6142e42.htm @php;
}

location @php {
    try_files $uri =404;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:/var/lib/php5-fpm/web2.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors on;
}

What is the point of the first location block? Wouldn't the end-result
be exactly the same if the content of the second block were to be moved
into the first block, and the second block eliminated? For example:

location ~ \.php$ {
    try_files $uri =404;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:/var/lib/php5-fpm/web2.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors on;
}

Everything "works" just fine; I'm simply curious if there is some
non-obvious reason for this "try_files trick" with a file that will
never exist (that HTML file doesn't exist and seems to have a
randomly-generated name -- presumably to ensure that it will *never* exist).

Perhaps this file is created in "Maintenance Mode", thereby causing all
requests to be redirected to the maintenance message page?

Thanks!

-Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20130701/da961273/attachment.html>


More information about the nginx mailing list