0

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 [email protected]

        <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, [email protected] 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?

5
  • 1
    You check the error log for more background information as by design the error message that a site visitor gets contains very little useful information. - Also following a manual for Apache 2.4 while you run on 2.2 might not yield optimal results.
    – HBruijn
    Apr 15, 2016 at 8:57
  • @HBruijn I know it's a tutorial for apache 2.4, but I've looked carefully as to realise which points need to be changed in case of incompatibilities. Where are the log files for apache, are they in /var/log? Which file do I have to look? Thanks!!
    – joninx
    Apr 15, 2016 at 9:17
  • Perhaps I do need to upgrade my Raspberry Pi from wheezy to jessie, so that I can install the latest version of each application.
    – joninx
    Apr 15, 2016 at 9:58
  • 1
    The error log is wherever you configured it...
    – HBruijn
    Apr 15, 2016 at 11:54
  • Finally, I updated Raspbian to jessie and I've got installed Apache 2.4. Anyway, I'm not able to make it work... I'm trying to configure it also with postgresql.
    – joninx
    May 4, 2016 at 8:05

0

You must log in to answer this question.

Browse other questions tagged .