Nginx忽略WordPress登录目录的HTTP身份验证
我在我的域的子文件夹中运行WordPress,以便在VPS LEMP堆栈上进行测试和开发。为了使用etxra层对Nginx忽略WordPress登录目录的HTTP身份验证,wordpress,http,authentication,nginx,Wordpress,Http,Authentication,Nginx,我在我的域的子文件夹中运行WordPress,以便在VPS LEMP堆栈上进行测试和开发。为了使用etxra层对wp login.php进行密码保护,我对wp admin文件夹使用了HTTP身份验证 问题是http身份验证被忽略。当调用wp-login.php或wp-admin文件夹时,它会直接进入正常的WordPress登录 我通过以下方式从命令行安装了所有内容: sudo apt-get install apache2-utils sudo htpasswd -c /var/www/bit
wp login.php
进行密码保护,我对wp admin
文件夹使用了HTTP身份验证
问题是http身份验证被忽略。当调用wp-login.php或wp-admin文件夹时,它会直接进入正常的WordPress登录
我通过以下方式从命令行安装了所有内容:
sudo apt-get install apache2-utils
sudo htpasswd -c /var/www/bitmall/wp-admin/.htpasswd exampleuser
New password:
Re-type new password:
Adding password for user exampleuser
我的Nginx配置文件如下所示:
server {
listen 80;
root /var/www;
index index.php index.html index.htm;
server_name eample.com;
location / {
try_files $uri $uri/ /index.html;
}
location /bitmall/wp-admin/ {
auth_basic "Restricted Section";
auth_basic_user_file /var/www/bitmall/wp-admin/.htpasswd;
}
location ~ /\.ht {
deny all;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
我已经尝试按照以下步骤更改nginx配置:
此代码将调用http身份验证,但当输入凭据时,浏览器将下载wp login.php
,而不是转到主登录屏幕
您能告诉我如何解决这个问题吗?问题是旧的location块没有将PHP配置传递给新的块,因此不会处理PHP请求。以下步骤解决了此问题:
location ~* /wp-login.php {
auth_basic "Restricted Area";
auth_basic_user_file PATH TO .htpasswd;
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
尝试
chown
将.htaccess
文件发送给nginx用户,然后chmod
发送给750
之类的文件。我以为nginx不支持.htaccess文件?我的意思是htpasswd
为WP安装正确设置了所有写入权限。
location ~* /wp-login.php {
auth_basic "Restricted Area";
auth_basic_user_file PATH TO .htpasswd;
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}