Dockerizing a dynamic Nginx-WordPress proxy is tricky business. I plan to bundle this all up in
bash scripts, but for now I am simply documenting the steps I took to configure the following system in my local environment:
What follows is not a production-ready path to deployment. Rather, it is a brute-force proof of concept.
Start a detatched MySQL container.
This one probably won’t cause any trouble, so I don’t need to see any output.
This is the WordPress instance you encounter when you land on the domain’s root.
This is the WordPress instance you encounter when you land on the domains
Notice the port. If I were to set it from
8082:80, it will redirect back to
8081, and I don’t know why yet.
This is the tricky part. I need to obtain the IPs assigned to my WordPress containers and set them in my Nginx
First, get the IP addresses of each running
This will output the IP. Make note of it, because I need to copy it to the Nginx’s
Get the IP addresses of each running
There’s a good chance it will be the next IP in line:
Now, create a
Copy and save the following:
proxy_pass IPs accordingly.
The main blog should now be accessible at http://localhost. The secondary blog at http://localhost/blog. Set up different blogs on each WordPress instance to confirm the system is working as designed.