View Single Post
Old 05-26-2017, 03:59 PM   #1568
MontyJ
Addict
MontyJ began at the beginning.
 
Posts: 224
Karma: 10
Join Date: Jul 2012
Device: Kindle
Quote:
Originally Posted by Calibius View Post
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...
Thanks for the ideas! As to using htaccess/htpasswd, I had assumed that was the only thing available IF I wanted apache authorization. I do have 40 or so users/passwords in my .htpassword file, tho I often 'test' with just one newly created one to make sure that copying the encrypted passwords from a previous apache install isn't causing problems.

I am going to go ahead and put the Require valid-user statement in the vhosts file and see what happens. I have tried it before, but started with default this time before I started mucking things up again...
MontyJ is offline   Reply With Quote