0

What's up! I am trying to install WordPress docker over HTTPS only. It works but fails to load the static images and javascript since the browser does not let them be loaded over plain HTTP. How can I switch them to be loaded over HTTPS also? My Dockerfile looks like this:

FROM wordpress:5.3.2-apache
EXPOSE 80
USER root

The SSL termination happens in traefik and all HTTP requests are redirected to HTTPS

Please take a look at the below image. The errors of static files unable to load over HTTP

The installation is done successfully and after installation, I do the following to make everything load over HTTPS. How can I do the same but BEFORE installation?

 if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
     $_SERVER['HTTPS'] = 'on';
 }
Hemen
  • 55
  • 1
  • 9
  • Since you're using Apache as web-server, check your `.htaccess` file if you have, or check your domain's Apache config file. You should tell him to redirect all requests to HTTPS. Check this and let me know if it worked: https://stackoverflow.com/a/27697308/5790653 – Saeed Apr 12 '21 at 18:34
  • All the WordPress-related files are copied by the image itself ( i don't exactly know how and from where!). I think the docker image checks whether or not there are already WordPress files in /var/www/html/. if not, it will copy them from somewhere. I can not edit them before installation. That seems to be the case! – Hemen Apr 12 '21 at 18:39
  • Also, all requests are redirected to HTTPS and SSL is terminated before it reaches the image. – Hemen Apr 12 '21 at 18:41
  • You can run `docker exec -it CONTAINER_NAME bash` and go to `/etc/apache2/ – Saeed Apr 12 '21 at 18:41
  • SSL is terminated before it reached the container. (by Traefik) – Hemen Apr 12 '21 at 18:53
  • I'm afraid I don't know about Traefik. – Saeed Apr 12 '21 at 18:57

0 Answers0