skip to Main Content

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…

2

Answers


  1. Chosen as BEST ANSWER

    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');
    

    (thanks to my friend Dario for the help).


  2. I use ngrok for tunnelling to my localhost, and the only way I could successfully run my environment over proxied https is by converting wordpress permalink url’s to relative urls using…

    https://wordpress.org/plugins/relative-url/

    The plugin is 2 years out of date but still does the job fine and allows my tunnelling to my localhost to run over https. Handy for localhost https endpoint access (without force define home/urls in wp-config.php)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search