Hosting a wordpress website in Synology NAS

Synology NAS is my favourite NAS hardware as it comes with not only storage function, but you can use it as your home entertainment system, CCTV storage, home server or business server. In this post, I will share how to run a WordPress website on the Synology NAS server.

For the demo purpose, I will use the Docker package that you can get it from the Synology Package Center. Not every single Synology NAS server able to support docker container, to check it, you can refer to the official website at https://www.synology.com/en-my/dsm/packages/Docker

For the container image, I am using the bitnami/wordpress and bitnami/mariadb image from official docker hub website.

Here is the overall steps to configure and run your own WordPress website in your Synology NAS:

  1. Install Docker package from Package Center
  2. Download the Bitnami WordPress and MariaDB images
  3. Create the dedicated network for the wordpress
  4. Create the MariaDB container using the GUI (optionally you can use SSH if you familiar with the terminal)
  5. Create the WordPress container using the GUI (optionally you can use SSH if you familiar with the terminal)
  6. Enabled the port forwarding in your home router
  7. Create the reverse proxy entry in your Synology login portal
  8. Point your domain name in DNS provider to your home IP (I’m using the CloudFlare as my DNS server), if you are using dynamic IP at your home, you can refer to Using custom domain on Synology NAS with Dynamic IP
  9. (Optional) Create the ACL to only allow CloudFlare IP to hit your website

This the high level overview network diagram for the demo

Step 1: Installing docker package from package center

First you need to log into your Synology GUI with the administrator credential, click on the package center and search for docker. Click on the install if you not yet done.

You can click here to check is your Synology NAS support the Docker.

Step 2: Downloading Bitnami WordPress and MariaDB images

Open the newly installed Docker package, go to registry and search for bitnami/mariadb and bitnami/wordpress.

If you wish to know more about bitnami/mariaDB and bitnami/wordpress, you can refer to the official docker hub page

bitnami/mariadb: https://hub.docker.com/r/bitnami/mariadb/

bitnami/wordpress: https://hub.docker.com/r/bitnami/wordpress/

Download the first image bitnami/mariadb
Download the first image from the list bitnami/wordpress
Once the image downloaded, you will see both the mariadb and wordpress are in your image list

Step 3: Create the dedicated network for better isolation

This is an optional step to create the dedicated network for your wordpress, by creating the network, you actually create the isolation networking environment to host the MariaDB and WordPress containers.

To create the network, just click on the network tab on the left menu, enter any name you like and leave the rest as default. Click on Add to complete the creation


After the creation of networking is done, you will see the wordpress appear in your network list.

Step 4: Create the MariaDB container

Now we can start to create the container, first we will create the MariaDB container then only the wordpress, because the database need to up and running before we can start to create wordpress container.

Click on the container from the left menu, then click on Create container, then select the bitnami/mariadb:latest and click next.

On the following page, just select the wordpress as your network, so now the MariaDB will be hosted in the wordpress network.

Click on next and come to the General Settings page, you can enter the container name as you like, we will use this name in the wordpress setup later to link both of the container.

You may need to limit the resources if you don’t want your MariaDB container to over utilizes your NAS resources.

Check the “Enable auto-restart” checkbox in order for your container to auto restart just incase you need to reboot your application or your NAS Server.

Click on the advanced settings to actually supply the additional environment variable to your container, for the available variable, you can always refer to the bitnami/mariadb page in the docker hub. https://hub.docker.com/r/bitnami/wordpress/

These are some of the environment variables that you need to supply:

ALLOW_EMPTY_PASSWORDyes
MARIADB_USER[your database username]
MARIADB_PASSWORD[your database password]
MARIADB_DATABASE[your database name]

After all the variable filled up, you can just click on save to proceed to the next step.

The next step is port settings, as we do not need to directly interact with the MariaDB, you can just leave the Local Port field as empty, mean that we don’t expose any ports to the local machine.

The following step is to create the persistent volume for the containers, but in this demo, I will just leave it blank, which mean I will not keep any file in my volume but everything in container it self, when I remove my container, all the data will be deleted as well, it’s recommended to create persistent volume if you use to host the production application.

If you wish to create the volume for your container, make sure you need to enable the permission for everyone in the file station, so that the container user able to write to the directory, else your creation of container will fail.

Preview your setting before creating the container.

Now you should see your mariadb container up and running, if you wish to check what happen inside the container, you can always select the container -> click on Details -> Logs

Step 5: Create the WordPress container

Right now we have our MariaDB container up and running, so the next step is to create the wordpress container.

To create the wordpress container, go back to the Docker application in the Synology NAS, on the left menu select container and click on create, then select the bitnami/wordpress:latest image. (optionally you can download a specific wordpress version base on the tag if you need it)

Now select the same network as per mariaDB for your wordpress container

Set the resources limitation so that the container will not fully utilize the CPU and RAM, also remember to check the Enable auto-restart to ensure that the container will be auto restart if you reboot the NAS or the application.

Click on advanced settings to supply the environment variables to the container.

For more environment variable that available, you can always refer to Bitnami/wordpress docker hub page at: https://hub.docker.com/r/bitnami/wordpress/

This is the sample environment variables that I use to create the demo wordprss site.

ALLOW_EMPTY_PASSWORDyes
WORDPRESS_DATABASE_USER[Database user set in the MariaDB Container]
WORDPRESS_DATABASE_PASSWORD [Database password set in the MariaDB Container]
WORDPRESS_DATABASE_NAME[Database name set in the MariaDB Container]
WORDPRESS_DATABASE_HOST[MariaDB container name]
WORDPRESS_USERNAMEadmin
WORDPRESS_PASSWORD123123qwe
WORDPRESS_FIRST_NAMEDavid
WORDPRESS_LAST_NAMECheong
WORDPRESS_BLOG_NAMEDemo
APACHE_HTTPS_PORT_NUMBER8443
APACHE_HTTP_PORT_NUMBER8080

After fill up the variable name and value, click on save to close the pop up.

Next step is to enter the port number that you want to expose, for this demo, I will expose the container port 8080 to the local port of 18080, container port 8443 to local port of 18443.

Local Port: the port number that accessible locally or from the local network, this port should be unique and not crash with any other port number that currently occupied by any other application/container

Container Port: the port number that the container listening

On the next page, you can create the volume if you wish to persistently store your data in the hard disk. It’s highly recommend to mount the volume from your NAS into the container if you are hosting your production application or you want to retain your data after you delete the container.

If you wish to create the volume for your container, make sure you need to enable the permission for everyone in the file station, so that the container user able to write to the directory, else your creation of container will fail.

But for this demo purpose, I will just leave it empty, which mean I’m just store everything in my container it self.

Preview all the configuration before proceed to create the container.

After the container created, you will see 2 containers currently running in the system, first one is the mymariaddb which is the database server and the second container is wordpress, which use to host the wordpress script and serve by Apache web server.

Selecting the container and click on the details, you can see all the container detail including the up time, environment variables, port numbers, cpu and ram usage and so on.

Let’s try to access my demo wordpress using the browser, to access it locally, I can just browse to the Synology NAS IP with the port number of 18080 (this is the port number that I expose during the creation of the wordpress container). You should see the wordpress default page.

At this point of time, our wordpress site is up and running, but only accessible locally, next we want to make the website publicly accessible by custom domain name from the public internet.

Step 6: Enabled the port forwarding in your home router

This is really depend on what home router you are using, so you may need to refer back to your router user guide on this. I will show the demo using my home router (TP-Link AC1200).

First I need to brose to the router admin console at http://192.168.0.1 and login with the admin username password. Next browse to the section call NAT Forwarding, under the NAT Forwarding I can create the Virtual Servers. This is where I can configure external and internal port as well as my internal IP Address.

My Synology NAS IP is 192.168.0.2, so I forward the public port 80 into my Synology NAS port 81. After save the configuration, I need to reboot my router in order for the new configuration to be refresh, again, it’s depend on your home router model, some router required to reboot but some may not.

Step 7: Create the reverse proxy entry in your Synology login portal

Now we already have our home router forwarding any traffic from port 80 public interface to our port 81 in Synology NAS. Which mean any one from the public internet when browse to my home public IP at port 80, they can actually hit my Synology NAS port 81, but now the docker container it self, so now I need to configure my NAS server to forward the incoming request base on certain criteria to reach my application, for this case is my wordpress website in the docker container.

To create the reverse proxy in your Synology NAS, go to Control Panel -> Login Portal -> Advanced -> Reverse Proxy -> Create

Next we need to ensure that the reverse proxy is listening on port 81 and forward any traffic that hitting the port 81 with the hostname of demo.david-cheong.com to the localhost port 18080. This is the port number that I assign to my wordpress container, and the container will know that the port 18080 is actually bind to the port 8080 of wordpress container.

So now we will be able to access the wordpress site from the public internet by browsing to my home public IP http://61.6.112.152/, but this is not a great way to host a public accessible website with pure IP address, furthermore my home internet package only come with dynamic IP, which mean after certain time or if I restart my home router, the IP may changed.

So the best way is to host a website is by create a subdomain name and point it to my home IP, so next time I just need to remember my domain name will do, instead of I need to find out what’s my current home IP address.

Step 8: Create the sub domain name and point it to the home IP

As I’m fans of CloudFlare, so I will using CloudFlare as my DNS server to host my domain name.

The first thing I need to do is login to the CloudFlare console, select the domain name that I want to use, and create the A record for the subdomain. You can refer to my another blogpost on how to use the custom domain with CloudFlare on Synology NAS with Dynamic IP.

But for this demo, I just manually enter my home IP address into CloudFlare console and set the proxied option on. With the proxied setting set to on, CloudFlare will actually hide up our IP address and only show the CloudFlare IP if you try to ping the domain.

After save the configuration, just wait for a minute or two, you can try to access the domain, now I managed to access my wordpress site which hosted in my Synology NAS. Because I’m in the same network with my NAS, so I need to test it from the public internet, else I not able to route out to the public internet and back again.
Yes, this is the page that I viewed using my mobile phone via the public internet, which mean all our configuration is working fine as per expected.

This is just a sample demo page for you to understand how to configure and host an application using the docker container, how to expose your home hosted NAS server to the pubic internet. With the help of docker containers, it’s make your Synology NAS even more powerful to run almost any application locally.

Leave a Reply

google.com, pub-3772983857049267, DIRECT, f08c47fec0942fa0
%d bloggers like this: