Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

Thanks

share|improve this question

2 Answers 2

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.

share|improve this answer

The correct answer is:

location /wp-admin { 
    allow 192.0.2.0/24;
    deny all;
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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