我使用mod_dbd和mod_authn_dbd来保护对我的网站的访问。 但似乎是不稳定的,几分钟后,重新启动Apache和一些请求,身份validation不再工作了,这个消息在Apache错误日志中:
[authn_dbd:error] [pid 21308] [client xxxxx] AH01656: Query execution error looking up 'mylogin' in database []
编辑更多细节的Apache日志:
[authz_core:debug] [pid 9307] mod_authz_core.c(809): [client xxxx] AH01626: authorization result of Require dbd-group mygroup: denied (no authenticated user yet) [authn_dbd:error] [pid 9307] [client xxxx] AH01656: Query execution error looking up 'mylogin' in database [] [core:trace3] [pid 9307] request.c(119): [client xxxx] auth phase 'check user' gave status 500: /private
并在mysql错误日志中:
[Note] Aborted connection 5000 to db: 'httpauthdb' user: 'httpauth' host: 'xxx.xxx.xxx.xxx' (Got an error reading communication packets)
我必须重新启动Apache才能使其工作,但不是很长时间。 我发现将DBDPersist(在dbd conf)设置为Off解决了我的问题,但不build议根据apache文档来这样做。
编辑 :查询与MySQL客户端工作相同的数据库,即使发生错误。
这里是一个虚拟主机中的configuration:
<Location /private> AuthName 'My private space' AuthType Basic AuthBasicProvider dbd AuthDBDUserPWQuery "SELECT password FROM clients WHERE username = %s" AuthzDBDQuery "SELECT groups FROM clients WHERE username = %s" Require dbd-group mygroup </Location>
在这里我的dbd_mysql.conf由apache加载
DBDriver mysql DBDParams "sock=/var/run/mysqld/mysqld.sock,user=httpauth,dbname=httpauthdb,pass=xxxxxxxx" DBDMin 4 DBDKeep 2 DBDMax 10 DBDExptime 300 DBDPersist On
apachectl -V的结果:
Server version: Apache/2.4.25 (Debian) Server built: 2017-01-25T22:59:26 Server's Module Magic Number: 20120211:67 Server loaded: APR 1.5.1, APR-UTIL 1.5.4 Compiled using: APR 1.5.2, APR-UTIL 1.5.4 Architecture: 64-bit Server MPM: prefork threaded: no forked: yes (variable process count) Server compiled with.... -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_SYSVSEM_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=256 -D HTTPD_ROOT="/etc/apache2" -D SUEXEC_BIN="/usr/lib/apache2/suexec" -D DEFAULT_PIDLOG="/var/run/apache2.pid" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_ERRORLOG="logs/error_log" -D AP_TYPES_CONFIG_FILE="mime.types" -D SERVER_CONFIG_FILE="apache2.conf"
和mysql版本:
mysql Ver 14.14 Distrib 5.7.17-13, for debian-linux-gnu (x86_64) using 6.3
关于问题从何而来的任何想法?