Nginx拒绝某个位置的特定文件类型

时间:2017-03-11 07:06:49

标签: nginx

我想拒绝例如位置/ files /

的filetype html

我的配置中有另一个位置块,如下所示:

location ~* \.exe$ { alias /var/www/test.html; }

它成功地拒绝了.exe文件的输出,但它是全局的,我想仅拒绝/ files / location的html文件,但它不起作用。

有人有建议吗?

1 个答案:

答案 0 :(得分:2)

您可以在nginx中拥有嵌套位置。

location /files/ {
    #put your /files/ location config here

    #This is a nested location with your regex
    location ~* \.exe$ {
        alias /var/www/test.html;
    }
}
相关问题