简体   繁体   English

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

[英]Nginx deny specific filetypes in a location

I want to deny for example the filetype html for the location /files/ 例如,我想拒绝位置/ files /的html文件类型

I have another location block in my config it looks like this: 我的配置中还有另一个位置块,它看起来像这样:

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

It successfully denies the output of .exe files but it's global and I want to deny html files only for the /files/ location but it doesn't work. 它成功地拒绝了.exe文件的输出,但是它是全局的,我只想拒绝/ files /位置的html文件,但是它不起作用。

Anyone has advice? 有人有建议吗?

You can have nested locations in nginx. 您可以在nginx中具有嵌套位置。

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

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

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

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