anei

Member
Feb 27, 2020
5
0
1
Italy
cPanel Access Level
Root Administrator
Hello everyone,

I'm trying to restrict the access to the login file by IP.

In .htaccess file I added the following lines:

<files login.php>
order deny,allow
deny from all
allow from my.ip.address
</files>

But It doesn't work because I access the web site and then, in the new tab I go in WHM => Apache Status the IP Client — (IP address of the user who requested the data) it is the same as the server...

Thank you!
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,028
313
cPanel Access Level
Root Administrator
Hey there! The code you have posted is the correct code to include in the .htaccess file for what you are trying to achieve. I'm not sure I understand why the IP address would be the same as the server IP - are you using any tools like Nginx or any other proxy services?
 

Handssler Lopez

Well-Known Member
Apr 30, 2019
72
22
8
Guatemala
cPanel Access Level
Root Administrator
Hello everyone,

I'm trying to restrict the access to the login file by IP.

In .htaccess file I added the following lines:

<files login.php>
order deny,allow
deny from all
allow from my.ip.address
</files>

But It doesn't work because I access the web site and then, in the new tab I go in WHM => Apache Status the IP Client — (IP address of the user who requested the data) it is the same as the server...

Thank you!
what you do is fine, in fact I have added a similar but general rule at the apache level to limit access to all wordpress websites

Code:
##login wp
<Files wp-login.php>
order deny,allow
deny from all
allow from 1.1.1.1
ErrorDocument 403 "Restricted access"
</Files>
 

anei

Member
Feb 27, 2020
5
0
1
Italy
cPanel Access Level
Root Administrator
Hey there! The code you have posted is the correct code to include in the .htaccess file for what you are trying to achieve. I'm not sure I understand why the IP address would be the same as the server IP - are you using any tools like Nginx or any other proxy services?
Yes, I'm using Nginx as reverse proxy. I tried to disable it but nothing changed.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,028
313
cPanel Access Level
Root Administrator
I don't have a good explanation for that behavior on my side. If you'd like us to take a look at the system we'd be happy to do that if you can submit a ticket to our team. If you're able to put in that ticket, just post the number here so I can follow along.