questions

How do asset links in WP page get built? I get http rather that https after moving to docker

Rate this post

I’m suppsed to move to docker (docker-compose) a wordpress site that already works “correctly” in cPanel. I say “correctly” as the “site url” and “wordpress site url” both report http:// rather that https.

In the cPanel setup you can visit http or https and any internal link to js and css use https. After moving to docker behind traefik load balancer I get the page with all links using http. That clearly breaks security and the site is unusable.

What’s the mechanism used to build up the links to assets? does it use some variables that can be set differently? My docker has apache and I’m using the same .htaccess (at least I’m using what is in the cPanel’s backup…).

If I force to https, /wp-admin becomes unreachable… Currently traefik serves correclty resources requested using both http and https.

EDIT: adding

$_SERVER['HTTPS']='on';
define('FORCE_SSL_LOGIN', true);
define('FORCE_SSL_ADMIN', true); 

does turn most internal links to https, but /wp-admin becomes unreachable (“you’re not allowed to visit thie page”). As an example it loads /wp-includes/js/jquery/jquery.js via http.

Why the Any hint is appreciated…

 

✔️Solution:

I solved it rearranging the order of the settings in wp-config.php.

wp-configi.php is not just a configuration file as the name suggests. You need to set _SERVER['HTTP'] before the last line:

$_SERVER["HTTPS"] = "on";
require_once(ABSPATH . 'wp-settings.php');

Leave a Reply

Your email address will not be published.

Back to top button