Support » Networking WordPress » Nginx with forced https – guidance found only for http

  • Resolved Nigel Harpur

    (@nigelharpur)


    System is Ubunti 22.04 with Nginx (only) and PHP 8.1 – running latest WP.

    My current site is a simple single instance and running very well – I have Nginx server blocks (80 and 443) setup to force https – with server names as orchardmusic.com and *.orchardmusic.com – all redirects working – so it routes correctly with/without www and always forced to https – letsencrypt certification. Very happy, but now I am ready to go multisite (with subdomain option). I have done the initial settings in WP config, so I now have Network setup tool ready to use in the WP settings menu. I do have a reasonable understanding but still not an ‘expert’ by any means.

    So… I am stuck/unsure on how to modify Nginx for multisite – found a couple or more really good guides but all code show is only in the http (listen 80) block. I don’t want to mess it all up by making assumptions, especially as it is all working so well at the moment. I will paste my Nginx WP config file below – hoping someone can help me with this as I am ‘so close’ – Sorry about the long post but figured to head off a few questions.

    server {
    		listen 80;
    		server_name *.orchardmusic.com orchardmusic.com; # Your website's domain name
    		return 301 https://$host$request_uri; # Redirect
    }
    
    server {
            listen 443 ssl;
            server_name *.orchardmusic.com orchardmusic.com; # Your website's domain name
    		ssl_certificate /etc/letsencrypt/live/orchardmusic.com-0001/fullchain.pem; # Path to the full chain of your SSL certificate
    		ssl_certificate_key /etc/letsencrypt/live/orchardmusic.com-0001/privkey.pem; # Path to the private key of your SSL certificate
    
            root /var/www/wordpress;
    
            index index.php;
    
            server_name 127.0.0.1;
    
            location / {
                    try_files $uri $uri/ /index.php?$args;
            }
    
            location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
            }
    }
    

    The page I need help with: [log in to see the link]

  • You must be logged in to reply to this topic.