LNMP配置——Nginx配置 ——访问控制

#vi /usr/local/nginx/conf/vhost/test.com.conf

写入:

server

{

    listen 80;

    server_name test.com test1.com test2.com;

    index index.html index.htm index.php;

    root /data/nginx/test.com;

    location /admin/

   {

        allow 192.168.63.139;

        allow 127.0.0.1;

        deny all;

   }

}

//使访问admin目录下只允许192.168.63.139和127.0.0.1访问

# /usr/local/nginx/sbin/nginx -t

 

 

# /usr/local/nginx/sbin/nginx -s reload

#mkdir /data/nginx/test.com/admin

#echo "123" > /data/nginx/test.com/admin/1.html

二、测验

#curl -x127.0.0.1:80 test.com/admin/1.html

123

 

 

在vmware中给虚拟机添加一块网卡,设置为仅主机模式,查看IP,使用IP为请求代理,访问test.com/admin/1.html

#curl -x192.168.244.128:80 test.com/admin/1.html -I

状态码403

 

posted @ 2021-03-10 16:01  清空。  阅读(71)  评论(0)    收藏  举报