“...I've been working since 2008 with Ruby / Ruby on Rails, love a bit of Elixir / Phoenix and learning Rust. I also poke through other people's code and make PRs for OpenSource Ruby projects that sometimes make it. Currently working for InPay...”

Rob Lacey (contact@robl.me)
Senior Software Engineer, Brighton, UK

htpasswd files and basic Apache authetication

Its been a long time since I needed to do any kind of basic Apache authetication so a quick reminder to myself more than anything.

Its easy to generate a new file with the username and password. Don’t use ‘-c’ the next time as you’ll lose the contents of your original file.

htpasswd -b -c /var/www/websitething/.htpasswd username password

Adding this to my basic VirtualHost config now restricts access to the site with my username/password. woo.

<VirtualHost *:80>
  ServerName
  DocumentRoot /var/www/websitething/public

  <Directory /var/www/websitething/public>
    AuthType Basic
    AuthName MyPrivateFile
    AuthUserFile /var/www/websitething/.htpasswd
    Satisfy All
    Require valid-user
  </Directory>

</VirtualHost>