sirx
sirx

Reputation: 55

Nginx deny specific filetypes in a location

I want to deny for example the filetype html for the location /files/

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.

Anyone has advice?

Upvotes: 0

Views: 244

Answers (1)

Farhad Farahi
Farhad Farahi

Reputation: 39277

You can have nested locations in nginx.

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

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

Upvotes: 2

Related Questions