Please support for more: http://www.webyang.net/Html/web/article_168.html
Some website systems require users to upload pictures and other files to certain directories. It is inevitable that the program has some loopholes, resulting in Users uploaded php, cgi and other executable files, causing the website to fall into a very difficult situation. At this time, we can use nginx to prohibit users from accessing executable files in these directories.
<ol> <li value="1"> <span>location </span><span>~</span><span></span><span>^</span><span>/(uploads|images)/</span><span>.*</span><span>\.</span><span>(</span><span>php</span><span>|</span><span>php5</span><span>|</span><span>jsp</span><span>)</span><span>$ </span><span>{</span> </li> <li> <span> deny all</span><span>;</span> </li> <li><span>}</span></li> </ol>
<ol> <li value="1"> <span>location </span><span>~</span><span></span><span>^</span><span>/(uploads|images)/</span><span>.*</span><span>\.</span><span>(</span><span>php</span><span>|</span><span>php5</span><span>|</span><span>jsp</span><span>)</span><span>$ </span><span>{</span> </li> <li> <span></span><span>return</span><span></span><span>403</span><span>;</span> </li> <li><span>}</span></li> </ol>
<ol><li value="1"> <span>error_page </span><span>403</span><span> http</span><span>:</span><span>//www.webyang.net/public/404.html;</span> </li></ol>
<ol> <li value="1"> <span>location </span><span>~.*</span><span>\.sql </span><span>{</span> </li> <li> <span> deny all</span><span>;</span> </li> <li><span>}</span></li> </ol>
In this way, the sql files in any directory will not be accessed by users.
The above introduces nginx configuration to prohibit access to directories or files, including vulnerability aspects. I hope it will be helpful to friends who are interested in PHP tutorials.