magic try_files语句的目的是什么?

维护由第三方设置的系统在nginx虚拟主机configuration中find以下内容

server { listen *:80; listen *:443 ssl; ssl_certificate /path/to/cert.crt; ssl_certificate_key /path/to/cert.key; server_name <server-name-here>; root /path/to/vhost/root; index index.html index.htm index.php index.cgi index.pl index.xhtml; error_log /var/log/ispconfig/httpd/domain-name/error.log; access_log /var/log/ispconfig/httpd/domain-name/access.log combined; location ~ /\. { deny all; access_log off; log_not_found off; } location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } location /stats/ { index index.html index.php; auth_basic "Members Only"; auth_basic_user_file /path/to/passwd/file; } location ^~ /awstats-icon { alias /usr/share/awstats/icon; } location ~ \.php$ { try_files /0816f18c2383162111fc93fe015c1607.htm @php; } location @php { try_files $uri =404; include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9010; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_intercept_errors on; include fastcgi_params; fastcgi_read_timeout 300; } client_max_body_size 24M; location / { try_files $uri $uri/ /index.php?$args; add_header 'Access-Control-Allow-Origin' '*.domain.name'; add_header 'Access-Control-Allow-Methods' 'GET, POST'; satisfy any; allow <white-listed-IPs>; deny all; auth_basic "Members Only"; auth_basic_user_file /path/to/passwd/file; location ~ \.php$ { try_files /0816f18c2383162111fc93fe015c1607.htm @php; } } location ~* ^.+.(css|js|jpg|jpeg|png|gif|ico|woff|ttf|otf|eot|svg|pdf)$ { access_log off; expires 1h; } } 

这看起来很简单,除了这个try_files /0816f18c2383162111fc93fe015c1607.htm @php; 声明。 磁盘上没有该名称的文件。 显然这是一些用于监视或切换虚拟主机的魔法,很难谷歌,因为文件名是完全随机的string。

任何想法是什么用于?

PS我们正在谈论Linux机器,它也安装了ISPConfig,不知道是否重要。 当我把机器拿过来的时候,Nginx的版本是1.2.0

这个try_files条目的一个合法用途是使进入维护模式的网站变得容易。 一旦在Web服务器上创build了该文件,就不会执行PHP脚本,只会显示该特定的.htm文件。

在维护过程中,执行复杂的更新更容易,不会以意想不到的方式造成站点中断。

文件名被select为这样,以便它不会与网站上的任何其他.htm文件冲突。

但是,这种实施维护模式的方式会在维护期间打破所有其他非HTML内容页面,如RSS提要,站点地图和JSON API。