If your website is behind a load balancer or other reverse proxy, and WordPress doesn't know when HTTPS is being used, you will need to select the appropriate <a href="https://ssl.webaware.net.au/https-detection/">HTTPS detection settings</a>. See my blog post, <a href="https://snippets.webaware.com.au/snippets/wordpress-is_ssl-doesnt-work-behind-some-load-balancers/">WordPress is_ssl() doesn’t work behind some load balancers</a>, for some details.