在nginx中回退到默认/共享文件

在nginx中回退到默认/共享文件,nginx,robots.txt,Nginx,Robots.txt,我希望有一个默认的robots.txt文件从一个共享的地方(绝对路径)提供,如果没有相对的 我试过了,但运气不好: location = /robots.txt { expires 30d; add_header Cache-Control public; try_files /robots.txt /var/www/shared/robots.txt =404; } 但它只返回404。我最终得到了这个似乎有效的结果: location = /robots.txt {

我希望有一个默认的robots.txt文件从一个共享的地方(绝对路径)提供,如果没有相对的

我试过了,但运气不好:

location = /robots.txt {
    expires 30d;
    add_header Cache-Control public;
    try_files /robots.txt /var/www/shared/robots.txt =404;
}

但它只返回404。

我最终得到了这个似乎有效的结果:

location = /robots.txt {
    expires 30d;
    add_header Cache-Control public;
    try_files /robots.txt @shared;
}

location @shared {
    root /var/www/shared;
}
不过我必须承认,我更喜欢“try_文件”,但它似乎不适用于绝对路径

如果有人有更好的/其他的解决方案,我很乐意看到