I have a Wordpress site running on nginx. What is the best way to restrict access to /wp-admin using nginx?

Thanks

link|improve this question

75% accept rate
feedback

2 Answers

up vote 4 down vote accepted

As per the Nginx documentation for the access module:

location /wp-admin {
    allow 192.0.2.0/24;
    deny all;
}

That would allow access from 192.0.2.0/24 (which is presumably your administrative network) whilst denying all access from the rest of the Internet. Obviously adjust the IP range(s) as needed.

If you wanted to do HTTP authentication instead, then you might look at the documentation for the HTTP basic auth module.

On the other hand, Wordpress administration is already authentication-protected, so with strong passwords, you shouldn't have a massive amount of trouble.

link|improve this answer
feedback

The correct answer is:

location /wp-admin { allow 192.0.2.0/24; deny all; }

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.