Force All set_url_scheme URLs to ‘https’

This was another fix that we needed to pursue when working with a site using a reverse proxy with WordPress.

The problem occurs since the originating site for the reverse proxy cannot be secured with an SSL. The final site will be secured with an SSL but all the functions that use the “is_ssl()” conditional for generating the default scheme are run on our originating site and will always return false.

This means that any plugin resources that correctly use the “set_url_scheme” for loading resources will be served via “http” on our final “https” site and cause mixed content warnings.

To get around this, we can filter the “set_url_scheme” function to force an “https” scheme on any URL that is processed through the reverse proxy. This snippet utilizes our reverse proxy conditional.

Exit mobile version