如何做到这一点Nginx的位置configuration

我现在有

location /folder1 { configuration goes here } location /folder2 { configuration goes here } 

我想通过使用mp4模块在这两个位置提供.mp4文件

 location ~ \.mp4$ { mp4; } 

什么是正确的方法来做到这一点? 如果我只是像上面添加location ~ \.mp4$ ,那么mp4文件将不会从位置文件夹丢失configuration吗?

 location /folder1 { folder1 config; } location ~* ^/folder1/.*\.mp4$ { folder1 config duplicated; mp4; } location /folder2 { folder2 config; } location ~* ^/folder2/.*\.mp4$ { folder2 config duplicated; mp4; } 

nginx不会像Apache那样把所有的configuration部分结合起来,以达到速度和简单性。 缺点是你需要在mp4文件的位置块中复制文件夹指令。

使用嵌套位置:

 location /folder1 { ... location ~ \.mp4$ { mp4; } }