Nginx auth basic won’t work for wordpress wp-login.php

I have used several rules to block wp-login.php with a htpassword. The htpassword module is working. I added it to root of the site and it worked. But wp-login.php is not working. Here’s my website http://www.digitalreborn.com/wp-admin

Here’s the passwd rule :

Read More
location ~* /wp-login.php {
    auth_basic            "Restricted Area: WordPress";
    auth_basic_user_file  /var/www/digitalreborn/.htpasswd;

    try_files $uri =404;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;

}

Related posts

Leave a Reply

1 comment

  1. Try this approach:

    $ htpasswd -bc /tmp/secure_admin.txt admin password
    

    Then on your nginx virtual host conf.

    location ^~ /wp-login.php {
        auth_basic           "Restricted Area: WordPress";
        auth_basic_user_file /tmp/secure_admin.txt;
    }
    

    Then restart the service:

    $ service nginx restart
    

    403 Forbidden after correct login:

    This can be caused by permissions or a non-existent or invalid
    directory index directive.