简体   繁体   English

Nginx - 在多个目录中搜索静态内容?

[英]Nginx - Search for static content in multiple directories?

Because of the way that our git repos are setup I have some static content that might be in one directory - and other content that might be in another directory. 由于我们的git repos的设置方式,我有一些可能在一个目录中的静态内容 - 以及可能在另一个目录中的其他内容。 How can I ask nginx to search in two places for a static file like a stylesheet? 我怎样才能让nginx在两个地方搜索像样式表这样的静态文件?

I originally thought that try_files had my answer - but I can't seem to get it to work. 我原本以为try_files有我的答案 - 但我似乎无法让它工作。

try_files $uri /dir1/static/$uri /dir2/static/$uri @missing;
location ~* ^/just_test/(.+)$ {
    root /some/path/to/web/root;
    try_files /just_test/1/$1 /just_test/2/$1 /just_test/3/$1 @missing;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM