Home  >  Article  >  Operation and Maintenance  >  How to set nginx upload directory without execution permission

How to set nginx upload directory without execution permission

WBOY
WBOYforward
2023-05-19 08:55:051172browse

Copy code The code is as follows:



order allow,deny
deny from all

There is also the one on the Internet that does not have execution permissions for the nginx upload directory

Copy code The code is as follows:

location ~ ^/upload/.*\.(php|php5)$
{
deny all;
}

On the surface, there seems to be no problem with these configurations Yes, this can indeed be said under Windows.
But *nux is different. Everyone knows that the *nux operating system is case-sensitive. If you change it to an uppercase suffix name such as *.php, it will be bypassed.
Here I will talk about my personal experience. Solution:

Copy the code The code is as follows:


//? is a string matching .php as much as possible, i is not case-sensitive, and then the colon is followed by the regular expression
order allow,deny
deny from all
< ;/filesmatch>

The above means that all PHP files in the /var/www/upload directory are not case-sensitive and will be refused execution based on the order, allow, and deny principles. PHP files are also applicable to nginx
Another method, we have all used this

Copy code The code is as follows:


php_admin_flag engine off

In comparison, I am still optimistic about a method                                                        

The above is the detailed content of How to set nginx upload directory without execution permission. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete