This website is running in a docker container behind Nginx Proxy Manager in my home network. I’ve used Cloudflare tunnel to accept public access.

It’s tricky to enable HTTPS in a setup like this and I got the ‘too many redirects’ error from the browser. I’ve worked it out successfully by referring to the solutions from [here].

1. The docker image I used is the official wordpress image from docker hub.

https://hub.docker.com/_/wordpress/

It relies on a MySQL database, so I used the official MySQL image for this.

https://hub.docker.com/_/mysql

2. Also, I’ve setup CloudFlare Tunnel to point the domain name to the NPM. Then in NPM, I’ve configured a proxy host to direct traffic to the container.

The CloudFlare SSL/TLS encryption mode is set to Full(Strict), then in the Tunnel, is set to forward to HTTP of the NPM IP.

The proxy host configuration uses HTTP scheme with the container IP and port. Create a new SSL certificate for this domain and Force SSL is NO. In the Advanced tab, add the following custom configuration.

proxy_set_header Host $host:$server_port;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Proto $scheme;

3. Edit the wp-config.php file. add code

$_SERVER['HTTPS'] = 'on';

restart container. Now, the website is working correctly with HTTPS

I’ve also used the Really Simple SSL plugin to troubleshoot SSL issues.

Leave a Reply