Reputation: 137
I am trying to restrict access to admin area of magento in nginx. We use to do following in apache but don't know how to do it in Nginx:
RewriteCond %{REMOTE_ADDR} !^116\.71\.8\.191
RewriteCond %{REQUEST_URI} admin [NC]
RewriteRule ^(.*)$ / [F,L]
Regards,
Steve
Upvotes: 3
Views: 3162
Reputation: 558
For Magento 2 with Varnish scheme
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;
}
Upvotes: 0
Reputation: 11
just add at
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;
}
Upvotes: -1
Reputation: 5277
location /admin {
allow 116.71.8.191;
# drop rest of the world
deny all;
}
And don't forget reload rules
/usr/local/nginx/sbin/nginx -s reload
More info can be found here: http://www.cyberciti.biz/faq/linux-unix-nginx-access-control-howto/
Upvotes: 3