wordpress 站点的 /wp-login.php 使用 htpasswd 受 HTTP 授权保护。Web 服务器是 Nginx。下面给出了相同的配置。
与插件关联的 URL 使用 wp-login.php?query-parameters 来管理内部用户。URL 的示例是:
http://beta.timepass.com/wp-login.php?action=wordpress_social_authenticate&mode=login&provider=Facebook
我只需要允许那些匹配查询参数的 URLaction=wordpress_social_authenticate
绕过 htpasswd。我尝试了几件事,但无济于事!Nginx 不接受auth_basic "off"
它的 if 条件。
Nginx 配置供参考:
server {
listen 80;
server_name beta.timepass.com;
root /var/www/projects/beta.timepass.com;
index index.php index.html index.htm;
autoindex off;
access_log /var/log/nginx/beta.timepass.com-access.log;
error_log /var/log/nginx/beta.timepass.com-error.log;
try_files $uri $uri/ /index.php?$args;
## Disallow direct access to wp-login.php
location ~* ^/wp-login.php {
#satisfy any;
#allow 192.168.1.0/24;
allow 192.168.1.157;
auth_basic "Site Needs You to Authenticate";
auth_basic_user_file /etc/nginx/htpass-beta ;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
expires off; ## Do not cache dynamic content
#add_header Pragma public;
#add_header Cache-Control "public, max-age=300";
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/projects/beta.timepass.com$fastcgi_script_name;
fastcgi_read_timeout 60s;
}
}
您应该为此使用映射,因为该
auth_basic
指令允许使用变量。例如 :