View Single Post
Old 05-26-2017, 03:41 PM   #1566
Calibius
Junior Member
Calibius began at the beginning.
 
Posts: 7
Karma: 10
Join Date: May 2017
Device: Kindle paperwhite 3
Have you tried setting up basic auth within the virtual host, or do you always use the .htaccess to do so?

Just out of curiosity, I set mine up with multiple users and with multiple databases to see if it worked. I was able to get it functioning with multiple users, differing configs, and everything seems to be working. Granted I'm using a Linode vps with Debian 8, so I have a lot more freedom than a QNAP, but it is working, which means it's something about the setup you have.


Here's what I have:
config_local.php with my basic preferences that I want to apply to everyone. (Such as SMTP server, all databases, user auth if using COPS instead of htaccess. [I'm using htpasswd so I don't have a cops_auth setting])

config_local.user1.php with only things for user1 (don't set everything that is also in config_local.php-- so just add things like title, databases that differ for this user, etc.)

config_local.user2.php etc. (Clarification: users who are in your .htpasswd that do not have their own config file will default to using config_local.php)

I apologize if I'm repeating things you know, but if using .htpasswd with apache2, make sure your .htpasswd is configured for each of your users. On my Debian setup, this was "sudo htpasswd /etc/apache2/.htpasswd user1", it then prompts for password. Then for each additional user do the same thing without the -c option. I'm assuming with QNAP it's similar (you may have to use full path for htpasswd bin? I'm unfamiliar with using QNAPs so I apologize for not having more info.)

Afterwards, I believe you have two options, you can enable http auth with either the virtualhost.conf file or with the .htaccess file. Leaving the .htaccess file standard, I used the virtualhost method by adding the following bit in red:
Code:
<VirtualHost *:80>
  ServerAdmin xxxxx@yyyyy.zzz
  ServerName  example.com
  ServerAlias example.com
  
  DirectoryIndex index.html index.php
  DocumentRoot /var/www/public_html
  
     <Directory "/var/www/public_html">
        AuthType Basic
        AuthName "Restricted Content"
        AuthUserFile /etc/apache2/.htpasswd
        Require valid-user
    </Directory>

</VirtualHost>
I hope this helps...

Last edited by Calibius; 05-26-2017 at 03:44 PM. Reason: clarification about configs
Calibius is offline   Reply With Quote