Posts Tagged ‘apache2’

htpasswd or htdigest ?

Friday, November 7th, 2008

Gotcha! Don’t make the mistake I just made when setting up digest authentication in apache2. Depending on whether you’re using basic or digest authentication, you need to use a different command line tool to generate your passwords. After fifteen minutes of confusion, I realised that I needed htdigest to generate my passwords rather than htpasswd, although this crucial fact is not obvious from a glance at the documenation.

A typical setup for digest authentication is:

<Location /some/url>
      AuthType Digest
      AuthName "realm"
      AuthDigestDomain /some/url
      AuthUserFile /path/to/.htpasswd
      Require valid-user
</Location>

Then use htdigest…

htdigest -c /path/to/.htpasswd realm username

Using name based virtual hosting with apache2 and SSL

Wednesday, September 24th, 2008

One of the things I found when getting my Wordpress installation going was that I wanted to run a seperate subdomain for it, whilst keeping my secure server that I use for developing websites running SSL on port 443.

Normally, to set up virtual hosting, I would add something like this in my site’s config file:

<VirtualHost *>

But to keep the hosts listening on the right ports, you need to add the port number to the wildcard:

<VirtualHost *:80>

Trouble was, when you use the NameVirtualHost directive in apache2, you can’t mix the port numbers.

The solution was found on Friend’s of Bart http://fob.po8.org/comment/reply/289

Simply use

NameVirtualHost *:80

NameVirtualHost *:443

Both in your apache2.conf file. Then in each of your site’s config file, use the explicit port number on the VirtualHost directive:

<VirtualHost *:80>

<VirtualHost *:443>