Drupal and reverse proxy: How to make Drupal aware that it's protocol is HTTPS?
It turns out the IP which should be in the reverse_proxy_addresses is neither the IP which you get when you ping the domain, nor the ID in the headers which you can inspect. Rather, you need to temporarily install devel_php on your site, and then go to /devel/php and enter dpm($_SERVER['REMOTE_ADDR']);. This will give you a result such as 172.18.0.5, which then goes in $settings['reverse_proxy_addresses'];
More info at https://blog.dcycle.com/blog/170a6078/letsencrypt-drupal-docker/