WordPress Multisite с поддоменами в блоке LEMP-сервера с SSL - PullRequest
0 голосов
/ 24 августа 2018

Я пытаюсь создать WordPress Multisite (поддомен) в блоке сервера в стеке LEMP (Ubuntu 18.04).Я следовал этому руководству для других моих блоков серверов с доменами, чтобы сделать их безопасными.Я довольно новичок в NGINX, поэтому я не очень разбираюсь в том, как комбинировать и создавать конфигурационные файлы NGINX от руки.

Мне удалось создать этот файл конфигурации, который позволяет мне просматривать основной домен, но ни один из поддоменов.Что мне нужно изменить, чтобы это работало?Я заранее благодарен за любые полезные советы!

map $http_host $blogid {
default       -999;

#Ref: http://wordpress.org/extend/plugins/nginx-helper/
#include /var/www/wordpress/wp-content/plugins/nginx-helper/map.conf  ;
}

server {
listen 80;
server_name www.example.com example.com *.example.com;
include snippets/letsencrypt.conf;
return 301 https://$host$request_uri;
}

server {
listen 443 ssl http2;
server_name www.example.com *.example.com;

ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
include snippets/ssl.conf;
include snippets/letsencrypt.conf;

return 301 https://example.com$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    root /var/www/example.com/html;

    index index.html index.php index.htm index.nginx-debian.html;

    server_name example.com *.example.com;

    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
    include snippets/ssl.conf;
    include snippets/letsencrypt.conf;

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { log_not_found off; access_log off; allow all; }
    location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
    expires max;
    log_not_found off;
    }

    location / {
    #try_files $uri $uri/ =404;
    try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
            include snippets/fastcgi-php.conf;

            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    }

    location ~ /\.ht {
            deny all;
    }
    location ~ ^/files/(.*)$ {
            try_files /wp-content/blogs.dir/$blogid/$uri /wp-includes/ms-files.php?file=$1  ;
            access_log off; log_not_found off;      expires max;
    }

location ^~ /blogs.dir {
    internal;
    alias /var/www/example.com/htdocs/wp-content/blogs.dir;
    access_log off;     log_not_found off;      expires max;
}
}

В настоящее время мои сайты доступны для моего другого рабочего блока сервера WP с обычной установкой WP.

server {
listen 80;
server_name example.org www.example.org;

include snippets/letsencrypt.conf;
return 301 https://$host$request_uri;
}

server {
listen 443 ssl http2;
server_name www.example.org;

ssl_certificate /etc/letsencrypt/live/example.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/example.org/chain.pem;
include snippets/ssl.conf;
include snippets/letsencrypt.conf;

return 301 https://example.org$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;

root /var/www/example.org/html;

index index.php index.html index.htm index.nginx-debian.html;

server_name example.org;

ssl_certificate /etc/letsencrypt/live/example.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/example.org/chain.pem;
    include snippets/ssl.conf;
    include snippets/letsencrypt.conf;

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { log_not_found off; access_log off; allow all; }
    location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
    expires max;
    log_not_found off;
    }

    location / {
    #try_files $uri $uri/ =404;
    try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
            include snippets/fastcgi-php.conf;

            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    }

    location ~ /\.ht {
            deny all;
    }
}
...