我试图限制访问在nginx的的Magento管理区域限制在Nginx的访问Magento管理区。我们用来做阿帕奇以下,但不知道怎么做,在Nginx的:通过IP
RewriteCond %{REMOTE_ADDR} !^116\.71\.8\.191
RewriteCond %{REQUEST_URI} admin [NC]
RewriteRule ^(.*)$/[F,L]
问候,
史蒂夫
我试图限制访问在nginx的的Magento管理区域限制在Nginx的访问Magento管理区。我们用来做阿帕奇以下,但不知道怎么做,在Nginx的:通过IP
RewriteCond %{REMOTE_ADDR} !^116\.71\.8\.191
RewriteCond %{REQUEST_URI} admin [NC]
RewriteRule ^(.*)$/[F,L]
问候,
史蒂夫
location /admin {
allow 116.71.8.191;
# drop rest of the world
deny all;
}
而且不要忘记重装规则
/usr/local/nginx/sbin/nginx -s reload
更多信息可在这里找到:http://www.cyberciti.biz/faq/linux-unix-nginx-access-control-howto/
只需添加在
Location/{
if ($remote_addr !~ "^116.71.8.191"){
set $rule_0 1$rule_0;
}
if ($uri ~* "admin"){
set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
return 403;
break;
}
对于Magento的2清漆方案
location ~* ^/(index\.php/admin|admin) {
allow 1.2.3.4;
try_files $uri $uri/ /index.php?$args;
location ~* \.php$ { try_files /dummy @proxy; }
deny all;
}
不知为什么它不工作。 – user1538621
所以问题在于它没有被https限制。你能告诉我如何限制它为SSL – user1538621
它应该为http和https工作。你可以完全配置'/ admin'位置吗? 'fastcgi_param HTTPS';'在那里? – Zyava