@Anyman

Почему переходит с non-www на www?

Здравствуйте

1ввод адреса в строку; => переход; 2итог
infoteka.pw => https://infoteka.pw
'http://'infoteka.pw => https://www.infoteka.pw
https://infoteka.pw => https://infoteka.pw

Проблема с этим переходом 'http://'infoteka.pw => https://www.infoteka.pw
В итоге, при запросе ответа сервера Яндекс, бот не может: "... скачать содержимое страницы" с таким содержимым infoteka.pw и http://infoteka.pw, ну и www.infoteka.pw

А вся проблема в SSL. Якобы, нет сертификата на www.infoteka.pw. Очень странно.
Если в IE перейти на 'http://'infoteka.pw и пропустить проблему, то редирект сработает.

Проблема появилась после обновления nginx.
Как решить ситуацию?

upstream php {
            server unix:/var/run/php5-fpm.sock;
    }
    server {
    listen               80;
    listen               443 ssl;
    server_name          www.infoteka.pw;
    root /srv/infoteka.pw;
   ssl_certificate /etc/letsencrypt/live/infoteka.pw-0001/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/infoteka.pw-0001/privkey.pem; # managed by Certbot

    return 301 $scheme://infoteka.pw$request_uri;
    location ~ /.well-known {
                allow all;
        }
}
    server {
        listen              80 http2;
        listen              443 ssl default_server http2;
        listen              [::]:443 ssl default_server http2;
        root /srv/infoteka.pw;
        server_name         infoteka.pw;
        index index.php index.html index.htm;

        set $root_path /srv/infoteka.pw;
        set $cache_uri $request_uri;
        set $skip_cache 0;
        set $cache_control 'public, store, must-revalidate';
        set $expires 24h;

    location / {
        index index.php;
        try_files $uri $uri/ /index.php?q=$uri&$args;

        ###No Cache###
        rewrite ^/favicon.png$ /favicon.ico last;
        rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    }
location ~ [^/]\.php(/|$) {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        fastcgi_buffers 4 512k;
        fastcgi_busy_buffers_size 512k;
        fastcgi_temp_file_write_size 512k;
        fastcgi_pass php;
        fastcgi_index index.php;
        fastcgi_cache WORDPRESS;
        fastcgi_cache_bypass $skip_cache;
        fastcgi_no_cache $skip_cache;
        fastcgi_cache_valid 200 60m;
        fastcgi_cache_lock on;
        client_max_body_size 5M;

        add_header X-FastCGI-Cache $upstream_cache_status;
        if (!-f $realpath_root$fastcgi_script_name) {
                return 404;
        }

        include fastcgi_params;
    }
    location ~ /.well-known {
                allow all;
    }
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
    }
    location = /favicon.ico {
                log_not_found off;
                access_log off;
    }
    location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
    }
    location ~ /\. {
                deny all; # запрет для скрытых файлов
    }
    location ~* /(?:uploads|files)/.*\.php$ {
                deny all; # запрет для загруженных скриптов
    }

    ###SSL###
    ssl_stapling on;
    ssl_stapling_verify on;
    ssl_session_cache shared:TLS:5m;
    ssl_session_timeout 5m;
    ssl_prefer_server_ciphers on;
    ssl_session_tickets off;
    ssl_certificate /etc/letsencrypt/live/infoteka.pw-0001/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/infoteka.pw-0001/privkey.pem; # managed by Certbot
    ssl_dhparam /etc/pki/nginx/dhparam.pem;
    ssl_ciphers 'HIGH:!aNULL:!MD5:!kEDH';
    ssl_protocols TLSv1.1 TLSv1.2;
    ssl_verify_depth 3;
    ssl_verify_client off;
    add_header Referrer-Policy "";
    add_header X-XSS-Protection "1; mode=block";
    add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
    add_header X-Frame-Options "sameorigin";
    add_header X-Content-Type-Options "nosniff";
    add_header Content-Security-Policy "default-src 'self' https: data: 'unsafe-inline' 'unsafe-eval';" always;
    add_header Content-Security-Policy-Report-Only "default-src https:; script-src https: 'unsafe-eval' 'unsafe-inline'; style-src https: 'unsafe-inline'; img-src https: data:; font-src https: data:; report-uri /csp-report";

    resolver 8.8.8.8 8.8.4.4 valid=300s;
    resolver_timeout 5s;
    charset off;

    error_page 403 = 404;

    keepalive_timeout 20 20;

    ###WORDPRESS###
    set $cache_uri $request_uri;

    if ($request_method = POST) {
        set $cache_uri 'null cache';
    }   
    if ($query_string != "") {
            set $cache_uri 'null cache';
    }   

    # Don't cache uris containing the following segments
    if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
            set $cache_uri 'null cache';
    }   

    # Don't use the cache for logged in users or recent commenters
    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
            set $cache_uri 'null cache';
    }
}
  • Вопрос задан
  • 131 просмотр
Пригласить эксперта
Ответы на вопрос 1
@Arik
Проблема с этим переходом

так у вас такого перехода и нет.

Оставьте у основного server'a только 443 порт, а 80 поднимите отдельный server, на котором сделайте переадресацию. только сразу используйте https, а не $scheme .
В целом удобнее отдельные server'a поднимать и делать прямые переадресации, у вас сейчас до 2 переадресаций может быть, например,
http://www.infoteka.pw -> http://infoteka.pw -> https://infoteka.pw
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы