50% Off Today Only! No Code Required

Nginx Multisite and WordPress Block Themes


, ,

When setting up Nginx to run with WordPress Multisite, it’s vital that each sub-domain have it’s own Nginx configuration:

map $http_host $blogid {
    default			0;
    example.com			1;
    ### the numbers represent the blod id and the fqdn of the domain pointed at this multisite instance
    food.example.com		2;
    clothing1.example.com	3;
    # clothing2.example.com	3;
    # shelter.examplet.com	4;
}

Then each subdomain for the Multisite should be:

##  FOOD SSL SERVER
server {
    listen 443 ssl;
    server_name food.example.com;

    include global/wp_multisite.conf;
    include global/http_headers.conf;
    include ssl/ssl_localhost.conf;
    include global/compression.conf;

    location / {
        proxy_set_header Host $host;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header  X-Forwarded-For $remote_addr;
	proxy_set_header  X-Forwarded-Host $host;
	proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://rhfsites;
    }
    access_log  /var/log/nginx/example.access.log main;
    error_log  /var/log/nginx/example.error.log error;
}

Failure to add the Nginx configs above will result in custom CSS and functions.php failing to load for each designated subsite. The CSS and custom functions.php will load from the first previous subsite configured in Nginx.

, ,

Leave a Reply