开发者

Turning on Apache Basic Auth causes server connection failure

开发者 https://www.devze.com 2023-04-11 14:22 出处:网络
I am trying to test the basic authentication module of apache httpd web server. For some reason when I turn it on, the browser cannot seem to even connect to the server. Details are below. any help wi

I am trying to test the basic authentication module of apache httpd web server. For some reason when I turn it on, the browser cannot seem to even connect to the server. Details are below. any help will be appreciated.

OS: Mac OSX
Apache/Mysql
Browser: Safari

I 开发者_JAVA百科have a mysql db "mydb" storing username and password in a table called "login". Password is encrypted using SHA.

I have a directory structure like

/Users/Myname/Sites
/Users/Myname/Sites/Secret

I want to secure the Secret folder.

In the httpd.conf I have the following lines

DBDriver mysql
DBDParams "dbname=mydb user=admin password=myadminpasswd"

DBDMin  4
DBDKeep 8
DBDMax  20
DBDExptime 300

<Directory "/Users/Myname/Sites/Secret">
 # core authentication and mod_auth_basic configuration                                                                                                                     
  # for mod_authn_dbd                                                                                                                                                       
  AuthType Basic
  AuthName "My Server"
  AuthBasicProvider dbd

  # core authorization configuration                                                                                                                                        
  Require valid-user

  # mod_authn_dbd SQL query to authenticate a user                                                                                                                          
  AuthDBDUserPWQuery "SELECT password FROM login WHERE username = %s"
</Directory>

After this I restart the apache httpd server. I cannot even access http://localhost anymore. It gives the following error: Safari can’t open the page “http://localhost/” because Safari can’t connect to the server “localhost”.

I was hoping to be able to access localhost but not http://localhost/~myname/Secret

Does anyone has any idea as to what went wrong?

I believe I can access the secret folder via http://mysername:mypasswd@localhost/~myname/Secret

Notes: I have made sure that the following is loaded in httpd.conf

mod_authz_user.so
mod_authn_dbd.so

thanks mbh


Please check your apache server logs and see what errors you get when restarting it with the auth turned on

0

精彩评论

暂无评论...
验证码 换一张
取 消