Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like to password protect port 2000 of a web server by embedding a directive inside of the directive of the apache config file. However it didn't prompt for a password as expected. This is what I had in the apache config file:

<VirtualHost *:2000>
  ServerName www.server.com
  ServerAdmin email
  DocumentRoot /var/www/html
  ErrorLog logs/server.com-error_log

  <Location / >
    AuthType Basic
    AuthName "TAP Surveillance"
    AuthUserFile /var/www/s2/.htpasswd-users
    Require valid-user
  </Location>
</VirtualHost>
share|improve this question

3 Answers 3

There doesn't appear to be anything incorrect with your configuration.

  • Did you restart apache after configuring this?
  • Check your logs for relevant messages.
share|improve this answer
    
I did restart and checked log file. Nothing. –  Jim Young Aug 3 '12 at 17:29

A couple reasons why I think it didn't work:

  1. I needed a corresponding NameVirtualHost *:2000 to go with the VirtualHost directive
  2. I was using a reverse ssh tunnel on that port so ssh was catching it before the web server. The web server that the tunnel connected to did not have password protection.

So now my question is how to password protect the server at the end of the tunnel. It is a simple server and not capable of passwords. That's why I was hoping to protect access to it via the apache server.

share|improve this answer
    
Umm, don't allow the tunnel and have all access go through Apache? You have to detail the architecture a bit more to get a reasonable answer, I think. –  cjc Aug 4 '12 at 13:49

Please try: location and DocumentRoot need identical

<VirtualHost *:2000>
   ServerName www.server.com
   ServerAdmin email
   DocumentRoot /var/www/html
   ErrorLog logs/server.com-error_log
   <Location /var/www/html >
    AuthType Basic
    AuthName "TAP Surveillance"
    AuthUserFile /var/www/s2/.htpasswd-users
    Require valid-user
   </Location>
</VirtualHost>

Then, restart Apache

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.