A few days ago I deployed a new website to digitalocean, as usual I would secure it using letsencrypt certificate into https. I also opt to redirect to https automatically by adding permanent redirect rule to the virtualhost settings.
Then the most annoying thing happen, I was stuck in an infinite redirection. Basically the browser said ERR_TOO_MANY_REDIRECTS.
After much googling and thinking, apparently it was because I use cloudflare as my cdn and DNS. The problem is I configured the SSL settings incorrectly, I was using flexible SSL. Changing the settings to full SSL fixed this issue straight away.
When using flexible SSL, cloudflare would use http connection to talk to my server while serving https to the outside world. This doesn’t work because the virtualhost rules that I was using is looking to redirect to https if the incoming connection is made with http.
Another possible solution is to rely on cloudflare itself to do the redirection and removing the virtualhost settings altogether.
Hopefully this post helps out those who encountered the same issue while using a CDN. I think most providers like akamai would have similar settings as well.
Categorised in: Uncategorized