WordPress is a popular platform for blogging and ecommerce.  WordPress .org provides free hosting and wordpress.com provides paid hosting service.  but I wanted a self hosted service  which I can host from my RPI.  Currently most of the broadband providers give good speed  for uploading and downloading. Cherry on top is that they are mostly unlimited. This configuration can be used by anyone from their home network. 

Today I would like to discuss installing  wordpress on docker. There is a good docker ready OS Raspberry Pi  called HYPRIOT,  which I used previously. I used home automation software like  home assistant, homie ESP8266, Portener along with NGNiX. This is   based  on a resbian with minimum packages and ARM docker compose. Apart from Hypriot  any OS with docker compose can be used.  I wanted my own blogging platform hosting privately in my home network.

In fact my initial blog ioblueprint.com  was hosted on RPI at home network.

Rpi ioblueprint server physical view

I already have different server containers running on my RPI so I will be using NGinx in the front end.  I will route all WordPress traffic through it.  I already have a docker composer script for other services so I will add another  entry for WordPress.  There is no requirement for dockerfile. Only it’s required for a fresh build. All images are hosted on docker hub. I will keep it for our convenience.

 WordPress needs  mySQL or Mariadb  for its database. I have used PHP 7.3 for the wordpress version. I tried to use all Alpine base versions because most of the current service in docker are Alpine on my RPI. So a single base image  can be used for all other docker images. Total  memory footprint will be less for the whole system. Ubuntu versions are also available on docker hub. Note all the images on my dockerhub have ARMv5, ARM64, X86, X64, ppc64 cross compiled. So no need to worry on your execution platform. Instead of RPI you can run it on any platform.

As of now I have to use  NGINX-PROXY  with docker-gen to  provide let’s encrypt companion support directly.  DockerGen supports us to dynamically add and remove virtual hosts. I  used it because there is a possibility of hosting multiple  wordpress  services from the same RPI. I am working on progress.  Otherwise simple let’s encrypt service nginx only can be used.  I will try to   it blog that later. 

Following is my network configuration.

ed66688226566b5af20d97c33acf4aeb

Problems I faced

  1. I use airtel fiber modem router which does not allow port 80 to be open for http server or any other use. So only option to use HTTPS on port 443
  2. I need to use a Letsencrypt certificate to be created and renewed each time.
  3. I need to configure the modem/router (my case airtel nokia 5G router). If I just carry the RPI to other network or want to run same server configuration to another place(another persons house) it need to be reconfigured on the router of that location 

Solutions:

First and second problems solved here.  third one  I also have a working solution based  on tunneling or VPN(tinc). That needs a little different configuration than this.It’s on testing. Another post I’ll discuss. 

Dynamic DNS client will update your public IP to the DNS provider mapping. so if your modem restart also your new IP will be updated for your  domain name. Dynamic DNS client I have used  was DDclient. My current ddns  provider is Dynu, any other also fine if you want to use. Just change the ddclient.conf line .

Letsencrypt bring your certificate for the word press for https.I used DNS-challenge on acme.sh which is needed when port 80 it is not available. TLS ALPN also can be used but that is not supported yet in the companion docker image. You need to change letsencrypt companion configuration if you want to use for current DNS01 or your http challenge. Detail of API credentials and secrets for your DDNS  provider is given in the companion documentation.

To use this configuration you need to change the open port  in your router configuration. map your RPI IP to the open port.

Dot env  file can be changed based on your requirement.it is the environment variables for the docker compose. You can change your domain name or  virtual host. chain pass of wordpress if needed.

Following is my github link where you can get the docker compose files/ startup scripts. Images are already in docker hub. This script is also usable for other platforms x86/amd64/armv32/arm64/ppc

Following is the corresponding Github link.
wordpress-lets-encrypt-ddns-docker