nginx

Blank browser tabs with HTTP2

Reading time of 204 words
1 minute
Reading time of 204 words ~ 1 minute


If you find this content useful, consider buying me a coffee
Or help me out by engaging with any advertisers that you find interesting

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. Error Code: INET_E_DOWNLOAD_FAILURE

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.

Broken config example
Don’t do this!
Working config example
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

Written by Ben Garrett

If you find this content useful, consider buying me a coffee
Or help me out by engaging with any advertisers that you find interesting