http/2 with Apache on Debian

One of the nice things to come out this year (at least on paper) is the the http/2 specification.
Most web servers still don’t support it as only the latest Apache (2.4.17) has inbuilt support for it, so only people who compile their own or use experimental distributions are lucky enough to get it.

Below is an easy patch to enable it on a stable Debian configuration, this server has been running part unstable for a long time but it does require some attention to detail.


  • Up to date stable Debian installation
  • Some nerves / acceptable downtime
  • Configured ssl certificate, there is virtually no support for non https http/2

/etc/apt/sources.list add:

deb unstable main contrib non-free

/etc/apt/preferences add:

Package: apache2-bin
Pin: release a=unstable
Pin-Priority: 800

Package: apache2-data
Pin: release a=unstable
Pin-Priority: 800

Package: apache2
Pin: release a=unstable
Pin-Priority: 800

Package: apache2-utils
Pin: release a=unstable
Pin-Priority: 800

Package: *
Pin: release l=Debian-Security
Pin-Priority: 999

Package: *
Pin: release a=stable
Pin-Priority: 700

Package: *
Pin: release a=unstable
Pin-Priority: 1


sudo apt-get update && apt-get install apache2

/etc/apache2/apache2.conf add:

ProtocolsHonorOrder On
Protocols h2c h2 http/1.1

This method can also be used to install a more up to date version of other packages, but beware that packages in unstable are compiled against unstable libraries so this might not be a great idea to start upgrading everything you see.

Calling Synchronous Methods Asynchronously

Using the BeginInvoke function is way to much fun and something that entry level C# programmers get their hands on fairly quickly. That doesn’t mean it doesn’t have its pitfalls as most don’t bother to read the documentation.

The Microsoft article clearly states:

  • No matter which technique you use, always call EndInvoke to complete your asynchronous call
  • EndInvoke blocks the calling thread until it completes

In situations where a blocking call is not a problem it is a quick and easy fix, but in most situations it just becomes tedious to clean up after yourself.

        public static void AutoEndInvoke(this IAsyncResult result, ISynchronizeInvoke control)
            Task task = Task.Factory.StartNew(() => { AutoEndInvokeTask(result, control); }, TaskCreationOptions.PreferFairness);
            task.ContinueWith(t => HandleException(t.Exception), TaskContinuationOptions.OnlyOnFaulted);
        private static void AutoEndInvokeTask(IAsyncResult result, ISynchronizeInvoke control)

Using the code is easy to:

            _window.BeginInvoke(new Action(OpenFileWindow)).AutoEndInvoke(_window);

It isn’t the cleanest of solutions, it spoils a whole thread so it might not be the best solution for very heavy situations (bulk loading invokes works way better in those cases). But it does alleviate most of the occasional BeginInvoke calls.