skip to Main Content

I have two Docker containers (WordPress and MySQL) and I installed Apache on the server.

So it looks something like this;
enter image description here

I am trying to add an SSL certificate to it with Certbot.

So far, my Apache configuration file is this;

<VirtualHost *:80>
  ServerName example.com
  ServerAlias www.example.com

  <Proxy *>
     Order deny,allow
     Allow from all
  </Proxy>
  ProxyPreserveHost On
  ProxyPass / http://localhost:4567/
  ProxyPassReverse / http://localhost:4567/
  <Location />
     Order allow,deny
     Allow from all
  </Location>
</VirtualHost>

And I have added this two lines of code to wp-config.php;

define('WP_HOME', 'http://example.com/');
define('WP_SITEURL', 'http://example.com/');

When I use certbot --apache and choose the domain to add the SSL certificate, the website "brakes"; no CSS, no JS, no images and I can’t access to the admin (to try to change http to https using Search and Replace);

I tried to change http with https and add define('FORCE_SSL_ADMIN', true); to wp-config.php but that didn’t work;

Do anyone know the perfect way to add an SSL to Dockerized wordpress container?

PS: I tried a desperate move to change manually all the http://example.com to https://example.com in all tables in the database. it didn’t work and it is a pretty stupid thing to do, but desperate times call for desperate measures.

2

Answers


  1. This needs to be https, otherwise your assets will load from http resulting in mixed content.

    define('WP_HOME', 'https://example.com/');
    define('WP_SITEURL', 'https://example.com/);
    
    Login or Signup to reply.
  2. This is the apache config file from bitnami images, maybe this helps:

    <VirtualHost *:80>
        ServerName wordpress.example.com
        ServerAlias www.wordpress.example.com
        DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
        Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
    </VirtualHost>
    
    <VirtualHost *:443>
        ServerName wordpress.example.com
        ServerAlias www.wordpress.example.com
        DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
        SSLEngine on
        SSLCertificateFile "/opt/bitnami/apps/wordpress/conf/certs/server.crt"
        SSLCertificateKeyFile "/opt/bitnami/apps/wordpress/conf/certs/server.key"
        Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
    </VirtualHost>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search