Forum Moderators: bakedjake

Message Too Old, No Replies

Nginx: how to disallow people to visit register.php and login.php?

         

abiao

11:12 pm on Dec 5, 2023 (gmt 0)

10+ Year Member



I plan to disallow certain ip to visit /login.php, and /register.php, but let admin to visit /admin/login.php, and /admin/login.php. how to set Nginx conf file, please?

Thanks in advance.

csdude55

7:11 am on Dec 11, 2023 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I don't use nginx myself, but best I can tell you would SSH to /nginx/yoursite.com and create a new file named access.conf. I suspect that you could name it anything you wanted as long as it ends with .conf, but the example I found said access.conf.

Then in that file, add:

location /login.php {
deny 1.2.3.4;
}

location /register.php {
deny 1.2.3.4;
}

location /admin/login.php {
allow 4.3.2.1;
deny all;
}


Then restart nginx.