Один из поддоменов продолжает перенаправлять на другой (sports.example.com -> news.example.com) - PullRequest
0 голосов
/ 20 июня 2019

Проблема: субдомен перенаправляется на другой

Я пытаюсь установить новый поддомен sports .example.com для моего сервера, и у меня есть другой поддомен, который в настоящее время работает нормально на news .example.com. Проблема в том, что каждый раз, когда я посещаю sports .example.com, он перенаправляет на news .example.com.

Фон

Оба домена являются сайтами WordPress, и я могу подтвердить, что новый действительно "правильно" разрешен при посещении sports .example.com / info.php , если я вручную коснитесь и отредактируйте файл info.php.

Вот файл конфигурации sports /etc/nginx/sites-enabled/sports.example.com:

server {
        listen 80;
        root /home/sd/sites/sports.example.com;
        index index.php index.html index.htm index.nginx-debian.html;
        server_name sports.example.com; 

        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 = /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;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/sports.example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/sports.example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = sports.example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        server_name sports.example.com;
    listen 80;
    return 404; # managed by Certbot
}

А вот и файл конфигурации для news поддомен (/etc/nginx/sites-enabled/news.example.com:

server {
        root /home/sd/sites/news.example.com;
        index index.php index.html index.htm index.nginx-debian.html;
        server_name news.example.com; 

        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 = /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;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/news.example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/news.example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = news.example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen 80;
        server_name news.example.com;
    return 404; # managed by Certbot
}

Я нашел этот вопрос , наиболее близкий к случаю, но у меня нет каких-либо прокси-серверов, установленных в моей системе, где есть еще 2 субдомена, обслуживаемых с того же VPS с тем же IP-адресом , Однако это несколько сайтов с Django, если это имеет значение.

...