Home » Wordpress » How to hide wp-admin AWS NginX

How to hide wp-admin AWS NginX

Posted by: admin November 30, 2017 Leave a comment

Questions:

I have a wordpress site that I would like to restrict access to the admin page. The server sits in AWS behind an ELB. I am setting up the location directive in my .conf file between the server {}’s. The config that I have set is not working as I can still access the page from an ip address which should be denied.

Can someone please give a look and give some guidance? Thank you!

location ~ ^/(wp-admin\.php) { 
real_ip_header X-Forwarded-For; 
set_real_ip_from xxx.xxx.xxx.xxx; 
allow xxx.xxx.xxx.xxx; 
deny all; 
}
Answers:

Use below for making your use case to work.

location ~ ^/(wp-admin|wp-login.php) {
real_ip_header X-Forwarded-For; 
allow xx.xx.xx.xx;
deny all;
}