Can add a content-md5 header on the fly or read the pregenerated value from a file.
Link to the original version: https://gist.github.com/sivel/1870822
Rackspace blog with comments: https://blog.rackspace.com/add-the-content-md5-http-header-to-nginx
This version, with modifications: https://gist.github.com/kwmiebach/2f03baaae7e4f86f9573f1f30818d36f
NGINX perl module http://nginx.org/en/docs/http/ngx_http_perl_module.html
apache2.4 ContentDigest directive: https://httpd.apache.org/docs/2.4/mod/core.html#contentdigest
RFC1864: https://tools.ietf.org/html/rfc1864
You can use the debian nginx package : https://packages.debian.org/stable/nginx-extras
sudo apt install nginx-extras
Or compile nginx yourself with perl module.
Choose one of the scripts, there are versions with or without checking of pregenerated md5.
Only the version ContentM5.md generates a base64 encoded value, which is what RFC1864 requires. It is designed to generate exactly the same value as the apache2 'ContentDigest On' directive from apache2 core: https://httpd.apache.org/docs/2.4/mod/core.html#contentdigest
To avoid confusion the other versions have been edited to generate a header with the custom name "Content-MD5-Hex".
Place the perl script in a perl library that nginx finds, and name it ContentMD5.pm
Example:
sudo mkdir -p /usr/share/nginx/perl/lib
cd /usr/share/nginx/perl/lib
sudo curl -O https://gist.githubusercontent.com/kwmiebach/2f03baaae7e4f86f9573f1f30818d36f/raw/ContentMD5.pm
ls
See the vhost examples below. Restart nginx afterwards:
servic nginx restart
Author: Matt Martz matt@sivel.net modifications by kwmiebach
License: http://www.nginx.org/LICENSE