Restrict the IP addresses of directories in nginx

Source: Internet
Author: User
Tags phpmyadmin

Nginx phpmyadmin is available for intranet ip users and for internet ip users (in the previous configuration, location ~ ^/Directory/use regular expressions with a higher priority than the location/configuration, so nginx cannot parse the homepage)

The code is as follows: Copy code

Server {

Listen 80;

Server_name example.com;

Access_log logs/access. log main;

Location /{

Root html;

Index. php index.html index.htm;

  }

Location ~ ^/Phpmyadmin /{

Allow 192.168.1.0/24;

Deny all;

Location ~ . *. (Php | php5 )? $ {

Root/var/mailapp/nginx/html;

Fastcgi_pass 127.0.0.1: 9000;

Fastcgi_index index. php;

Include fastcgi_params;

      }

  }

Location ~ . *. (Php | php5 )? $ {

Root/opt/nginx/html;

Fastcgi_pass 127.0.0.1: 9000;

Fastcgi_index index. php;

Include fastcgi_params;

   }

}

We can also configure it like this

The code is as follows: Copy code
Server {
Listen 80;
Server_name example.com;
Access_log logs/access. log main;
Location /{
Root html;
Index. php index.html index.htm;
        }
Location ~ ^/Download /{
Allow 192.168.1.0/24;
Deny all;
Index. php index. do index.html index.htm;
Location ~ . *. (Php | php5 )? $ {
Root/var/mailapp/nginx/html;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Include fastcgi_params;
                                }
                        }
 
 
Location ~ . *. (Php | php5 )? $ {
Root/opt/nginx/html;
Astcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Include fastcgi_params;
                      }
 

 
Restrict a specified connection to only allow access from a specified IP address

Related Article

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.