nginx针对某个url限制ip访问,经常使用于后台访问限制【转】

假如个人站点后台地址为: http://www.abc.net/admin.php 那么我想限制只有个别ip能够访问后台,那么须要在配置文件中增长:php

    location ~ .*admin.* {
        allow 1.1.1.1;
        allow 12.12.12.0/24;
        deny all;
        location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass  unix:/tmp/php-fcgi.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
        }
    }

须要注意的是,在这个location下也得加入php解析相关的配置,不然php文件没法解析。html

 

转自nginx

nginx针对某个url限制ip访问,经常使用于后台访问限制 - flyoss - 博客园 https://www.cnblogs.com/flying1819/articles/9162332.htmlurl

相关文章
相关标签/搜索