Can anyone explain the reason of adding the following lines, in Nginx config, when used with php-fpm
location ~ \..*/.*\.php$ {
return 403;
}
Thanks.
|
|
|
You'd better read about the regular expression in order to understand this. The above config means that a request begin with a dot, followed by any characters, then slash, and end with something.php will be forbidden, for eg:
|
|||
|
|
There are some long threads about Drupal, Wordpress, Squirrel etc pass their parameters to scripts through queries like If you're using CGI to pass the request to a backend, you need to pass it in a parameter called PATH_INFO. The php developers have included a feature (stupidly enabled by default) that makes use of this. This leads to a security problem with most common Nginx setups. Someone uploads a malicious php file to your server, say with a jpg extension. Then they go to Because it ends in You can imagine the rest. what the regular expression means is that any direct request to any file in any subdirectory is to be forbidden [return 403] if the file ends with .php [the .php$ part with $ showing the end of the line, whatever ends with that] to understand that or regular expressions in general you should probably search the nginx documentation or regular expressions in general |
||||
|
|
|
See here: http://forum.nginx.org/read.php?2,88845,88996 Long story short, in some setups, someone could upload a malicious file (JPG, whatever) and get it processed by PHP. |
|||
|
|