I've got a raspberry pi 1 which serves web pages using apache 2.22. I've done some research and I found a way to secure "pages" using a database (mysql in this case).
I've found this little guide to make it work (also checked the official documentation). Created a database called apache and a table named password (the same as in the guide). Then, I added the db related configuration stuff to my site's configuration file. This is the piece of code:
DBDriver mysql
DBDParams "host=localhost port=3306 dbname=apache user=myuser pass=mypass"
DBDMin 2
DBDKeep 4
DBDMax 10
DBDExptime 300
...
# A virtualhost
<VirtualHost *:80>
ServerName subdomain.domain.com
ServerAdmin mymail@gmail.com
<Location />
AuthName "Identification to my page"
AuthType Basic
AuthBasicProvider dbd
# Also tried this line, replacing the other AuthDBDUserPWQuery below, but no luck
#AuthDBDUserPWQuery "SELECT encrypt(password) AS password FROM password WHERE username=%s"
AuthDBDUserPWQuery "SELECT `password`.`password` FROM `apache`.`password` WHERE `password`.`username`=%s"
Require valid-user
</Location>
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyRequests Off
ProxyPreserveHost On
ProxyPass "/" "http://192.168.1.5:32400/"
ProxyPassReverse "/" "http://192.168.1.5:32400/"
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/web
RewriteCond %{HTTP:X-Plex-Device} ^$
RewriteRule ^/plex/$ /web/$1 [P]
</VirtualHost>
...
When I enter subdomain.domain.com, the page request username & password but, after that, I get this page:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, mymail@gmail.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/2.2.22 (Debian) Server at subdomain.domain.com Port 80
So, the question is simple, what am I doing wrong? How to make mysql auth work here?
Thank you in advance.
EDIT 1:
I updated raspbian from wheezy to jessie and now I've got Apache Httpd 2.4 installed instead of 2.22.
Could somebody provide some rapid explanation to make database (mysql or postgresql) authorization work on VirtualHosts?