Nginx only allows you to perform PHP program configuration

Source: Internet
Author: User
Tags gz file

Method one, nginx limit suffix

Solution:

The code is as follows
Location ~*. (Txt|doc|sql|gz) $ {
if (-f $request _filename) {
Break
}
}

The code above restricts the TXT doc sql gz filename suffix from being accessed if requested to jump out.

Of course, if you want to be more stringent, it can also use the following:

The code is as follows
Location ~*. (Txt|doc|sql|gz) $ {
Deny all;
}

This completely disables access to the TXT doc sql gz file suffix. Look at everyone's own choice.

Method Two, today I thought of another method of restriction (System: CentOS 5.9)

  code is as follows &nbs P;

Server
{
    listen;
  &nb Sp server_name  www.111cn.net;
    root/var/www/vhosts/www.111cn.net;
    Location/
    {
        index index.php;
        set $is _php ' no ';
        if (!-f $request _filename) {
             set $is _php ' yes ';
       }
        if ($request _filename ~ (. php.*)) {
             set $is _php ' yes ';
       }
        if ($is _php ~ ^no$) {
             return 404;
       }
   }
    Access_log/var/log/www/blog.slogra.com.access.log;
}

Summary

Nginx If you do not allow PHP support we can configure the environment is not configured PHP environment can be, this is better solved, if the configuration of the PHP environment we can directly delete the PHP environment.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.