假如個人站點後臺地址爲: 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