Nginx - Access Control

Access control is the only certain ip access,

Based on IP:

Create a directory under the root directory two a,

  [root@oldboy--01 nginx]# cd html
  [root@oldboy--01 html]# ls
    50x.html a b index.html web01 web02

 

LOCATION / A {
  the allow 10.0.0.200; # only native ip (10.0.0.200) access, the other access ip returns 404
   the deny All; # deny all
   return 404; # 404 returns

   return img # Return to image

   return 503 # confuse the enemy

}

 

 

 

 

 

 

 

 

Access to the physical machine 10.0.0.200/a, is limited

 

 

 

 

Based account password:

 

 

Download dependencies: yum -y install httpd-tools

  

 

Create an account profiles etc directory: mkdir / etc / nginx / htpasswd

  

 

Create a user

  

nginx.conf verification information and create two paths

  

Root directory create two files b

  


Implement login authentication, if the board does not go up, the password is not encrypted

  

 

Create an encrypted

  

 

View to create a user: vim / etc / nginx / htpasswd sky

  


Login successful

   

 

Guess you like

Origin www.cnblogs.com/sunny666/p/11057876.html