Redirecting Apache HTTP to HTTPS

Now that everyone can enjoy and use free SSL certificates from Let’s Encrypt, let’s all encrypt!

To forward HTTP requests to secure HTTPS, there are multiple options.

If you’re using some kind of panel to edit Apache configuration (like ISPConfig) that does not allow to edit the virtual host for HTTP separate from the virtual host for HTTPS, you can use this configuration in both configuration containers:

RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

If you’re able to edit the virtual host for HTTP separately, Apache recommends using “Redirect”:

<VirtualHost *:80>
    Redirect "/" ""

<VirtualHost *:443>
    # ... SSL configuration goes here

By the way: if you’re using ISPConfig, I can recommend installing the Let’s Encrypt plugin from The plugin will be included into the upcoming new version of ISPConfig >3.1.

Restore trashed mails from dovecot maildir

To remove the “T”rashed flag from mails in a maildir, the files need to be renamed.

rename 's/(.+),ST$/$1,S/' ./**/*
rename 's/(.+),RST$/$1,RS/' ./**/*
rename 's/(.+),STab$/$1,Sab/' ./**/*
find . -type f -regex '.*,\(ST\|RST\|STa\|STb\|STab\)' -exec echo `echo {}` \;

I have also created a script which can be executed in the Maildir, searching for files and renaming the files:

AngularJS ng-options syntax

I keep forgetting the correct syntax for ng-options in angular dropdowns. The documentation can be found here:

The syntax used in the documentation is a bit confusing:

select as label for value in array

A concrete example for the syntax would look like this:

item.Id as item.Name for item in itemSource

I hope this helps myself and maybe someone else as well…

Running ASP.NET vnext on Ubuntu Linux

After reading a lot about ASP.NET vNext I finally found an hour to give it a try. I only got as far as running the first sample webs, but it’s very nice to see it work.

There where some steps I had to take to get it up and running: is a good starting point. Starting with the command to install the basic kvm script I already got kvm and was almost able to restore packages.

curl -sSL | sh &amp;&amp; source ~/.kre/kvm/

The next step was to install Mono from

sudo apt-key adv --keyserver --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
apt-get update
apt-get install mono-complete

Next I cloned the aspnet Home samples:

git clone --depth=1 aspnet.Home
cd aspnet.Home/samples/HelloMvc/

Ready to go!

kpm restore

System.IO.IOException: The authentication or decryption has failed. —> Mono.Security.Protocol.Tls.TlsException

Some NuGet packages failed to restore because the certificate didn’t seem to be validated on my system. After some searching I found this helpful page:

Executed this scripts (with some manual approvals in between!):

sudo certmgr -ssl -m
sudo certmgr -ssl -m
sudo certmgr -ssl -m
sudo certmgr -ssl -m


kpm restore

later, all packages restored perfectly.

Run the web:

k kestrel

– next error, null reference:

Again the page helped with the script:

tar -xvf libuv-v1.0.0-rc1.tar.gz
cd libuv-v1.0.0-rc1/
./ -f make -Duv_library=shared_library
make -C out
sudo cp out/Debug/ /usr/lib/
sudo ln -s /usr/lib/

So maybe things would have been faster using the setup script from Punit Ganshani in the first place, which can also be found on github:

In the end, this was what I saw: aspnet-linux

Next: Using to edit the project in Sublime…

Sublime Text customization settings

Here’s a backup of my custom settings for my favorite text-editor Sublime.

Default (Windows).sublime-keymap

	// Add 7 to toggle_comment command for German keyboard handling
	{ "keys": ["ctrl+shift+7"], "command": "toggle_comment", "args": { "block": true } },


	"word_wrap": "false"

automysqlbackup – Backup databases on server

The easiest way that I have found for an advanced backup of all databases on a web hosting server was using the automysqlbackup tool.

By default the tool creates backups with automatic daily, weekly and monthly rotation. The backup files are being compressed and will be placed into your configured backup folder. Email notifications and a lot of additional options can be configured.
Of course the backup folder would then have to be backed up onto some other medium like a tape or remote servers.

automysqlbackup can be installed by cloning my fork from or downloading the original files from

git clone

After cloning, simply run the setup script:

cd automysqlbackup

The executable script will be placed in /usr/local/bin/automysqlbackup using the default settings. The default configuration will be placed in /etc/automysqlbackup.

Next, update your server configuration in /etc/automysqlbackup/automysqlbackup.conf and/or /etc/automysqlbackup/myserver.conf – details can be found in the projects README file.

A run script is provided in /etc/automysqlbackup/run which can be used to setup a daily cronjob with the example-cron-file located in the same directory.

# cat example-cron-file
# Put this file into /etc/cron.d and adjust to your needs.
# Run the mysql backup scripts every morning at 4.30 h:
30 4 * * * root /etc/automysqlbackup/run

With this simple setup you’ll have a very advanced backup of all MySQL databases on your server within minutes. Thank you “wipe_out“.

Must-have software tools (2014!)

Spotify, Sublime, Cmder
Spotify, Sublime, Cmder

I’m starting to build my list of software that is the first to install on a new system:



  • Cmder – finally a really nice console for Windows with almost everything I’m used to from Linux, includes git command line and tab auto-complete (with ending slash 😛 )
  • (Clover – tabbed windows explorer – I’m experiencing some issues with clover and currently don’t use it)
  • Greenshot – advanced screenshot creation and editing
  • Microsoft Visual Studio (C# web development)
  • Ditto (Clipboard Manager)
  • KatMouse (scroll in inactive window)
  • 7-zip


The obvious (for completeness sake) and then some…

Software development stuff

Also a lot is going on in the browser I guess. These are some of the most important web tools I use every day:

Categorized as Tools

Don’t use magic numbers

Quick note to start a new category on this blog: Good practices/Training

Everyone who doesn’t know what a “Magic number” in coding is, please quickly read this:

In some rare cases it might be allowed to use magic numbers (like 0/1 or in a circles calculation you may use 90/180/270/360 if it is clear why it’s being used). But in all other cases you have to explain such numbers – and the best way to do that is naming a variable or constant.


double angle = currentAngle + (angleSize / 3);

Why is this divided by 3?

angle = currentAngle + (angleSize / 3.5);

Why is this divided by 3.5?

The very least you can do here is add a comment with a short explanation.

OpenWRT on TP-Link TL-WDR4900

My wifi connections at home have been really slow using a really old AVM Fritz!Box, so I decided to upgrade to a TL-WDR4900. (The only thing still missing is 802.11 ac but the cheapest router providing that would be the Asus RT-AC66U AC1750 for twice the price of the TL-WDR4900, so that wasn’t worth it for me.)

I’m only writing this blog post because I found it really hard to get the right information on how to install OpenWRT – the wiki entry only scared me away because it doesn’t mention the simple method. The simple method is: Download firmware, upgrade, configure, done. (I can only speak for the v1 variant though.)

In this directory you’ve got to select the right binary:

And this is the right binary: openwrt-mpc85xx-generic-tl-wdr4900-v1-squashfs-factory.bin

After upgrading the firmware, the most simple way is to telnet to your machine:


Install luci

Configure your router from

Update (2014-11-24):
To allow multiple outgoing VPN PPTP connections, the package “kmod-gre” is needed (“Generic Routing Encapsulation support”).

opkg install kmod-gre