How to set up a server to host WordPress MultiSite, on multiple containers, all behind a single IP address.
Apache as a Reverse Proxy for Virtual Hosts
We all know how to do VirtualHosts on Apache, but what if you want to run a web application inside a container, or on another box, or in a virtual machine?
You need to turn Apache in to a reverse proxy. This is also called a gateway. It’s operation is pretty straightforward, and described in the Apache2 docs:
ProxyPass "/foo" "http://example.com"
That’s pretty simple. When the user hits /foo, they get the pages from example.com.
You can use the ProxyPass directive in a VirtualHost section.
On Debian systems, you set up virtual hosts with separate config files. My current one looks like this:
<VirtualHost 216.240.146.66:80>
ServerName slaptech.net
ProxyPass "/" "http://example.com/"
ProxyPassReverse "/" "http://example.com/"
</VirtualHost>
Again, it’s pretty straightforward. I have a domain, slaptech.net, that resolves to the above IP address.
When the Host header matches slaptech.net, it matches this VirtualHost scope. The server then maps the root of the URL, / , to requests at example.com.
See the Apache mod_proxy docs for more details.
nginx as a Reverse Proxy
Setting Up Let’s Encrypt Certificates
Setting Up a Network of Apache + PHP Containers
Setting Up Minimal Email Sending on Alpine Linux
Setting Up a Shared File Space
Setting Up Shell Aliases to Run WP-CLI Within Containers
Installing WordPress MultiSite
Setting Up a New Site for a Domain
Adjusting the File Upload Limits
In WordPress
In the Container’s PHP and Apache2
In the nginx Reverse Proxy
Migrating a Site from One Installation to Another
Create a new.example.com Domain Name
Set Up a New Site on the Target WP Installtion
Export the Content from the Original Site
Import the Content on the New Domain
Changing the Reverse Proxy and Virtual Hosts to Send Traffic to the New Site