Linux · nginx · Server

Blank browser tabs with HTTP2

I was reconfiguring a nginx server to add HTTP2 support with ALPN plus add some updates to its Content Security Policy. Everything worked fine when testing and troubleshooting with Chrome. However, I ran into some problems once I tried the new changes with both Firefox and Edge as nothing rendered in the browser tabs!

A check of the Network Developer Tools showed a request header sent by Firefox, but no data was receiving. Edge and Internet Explorer are polite enough to give me an error message to help troubleshoot. But it is so generic that it doesn’t help.

The connection to the website was reset.

After much searching in the wrong places, I discovered my problem.
Turns out when using HTTP2 in Firefox, Internet Explorer and Edge you should not have any newline characters in your HTTP response headers. I had broken up my Content Security Policy over multiple lines to be more legible. But it caused these browsers to reject the new HTTP headers and terminate the HTTP connections without warning, lesson learned.

A broken nginx configuration
Don’t do this!
A working nginx configuration
No matter how cumbersome you need keep each header entry to a single line

See: Line breaks in HTTP/2 headers are no longer allowed

One thought on “Blank browser tabs with HTTP2

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s