• Plesk Uservoice will be deprecated by October. Moving forward, all product feature requests and improvement suggestions will be managed through our new platform Plesk Productboard.
    To continue sharing your ideas and feedback, please visit features.plesk.com

Nginx IP protected directory not working

Patrick1

New Pleskian
Dear readers,

I searched the web endlessly but cant seem to figure this out.

I have several customers with wordpress domains. I want to protect these directory's with Nginx on a plesk 12 machine. I thought something simple will do, but i just spent all sunday afternoon getting it to work (what else is new)
.
I thought ;
location /wp-admin/ {
allow 123.123.123.123;
deny all;
satisfy all;
}
would do the trick, but no go, nginx isnt passing it to apache by the looks of it. I tried all kinds of possible solutions but cant get it to work. It works with files though. The logfile says directory index of "/var/www/vhosts/testdomain.eu/httpdocs/wp-admin/" is forbidden. This makes sense, since its turned off.

any suggestion on how to get this to work with plesk 12 and nginx ?
Regards,
Patrick
 
I figured out where the real problem is, its is because nginx talks to apache, so apache thinks that all requests
are coming from nginx.
I found out that X-real-IP is forwared to apache, but i cant make use of that in .htaccess.

So, how can i still make use of .htaccess files ?

Patrick
 
Found it.

Like i said, the real problem is that all calls to apache come from nginx.
To make use of the .htaccess again do the following in .htaccess;

Deny from All
SetEnvIF X-Forwarded-For "1.2.3.4" AllowIP
SetEnvIF X-Forwarded-For "2.3.4.5" AllowIP
Allow from env=AllowIP
Allow from 1.2.3.4
Allow from 2.3.4.5

then you can mak use of the .htaccess again like you used to.
I hope i save someone some time with this post.

Patrick
 
Back
Top