Проблема с чистыми URL и HTTPS

Главные вкладки

Аватар пользователя bsc-man bsc-man 10 октября 2018 в 14:07

Добрый день.

У меня есть мультисайтинг с 3 сайтами:

- one.com

- add.one.com

- two.com

Домен one.com работает с платным сертификатом ssl: все ссылки открываются на обоих сайтах one.com и add.one.com с http / https.

Недавно я установил бесплатный сертификат Let's Encrypt для two.com. После этого:

  • если использовать http -- сайт, отлично работает с/без чистых Url's
  • если использовать https с чистым Url -- откроется только главная страница, а другие выдают ошибку 404
  • если использовать https без чистых Url -- большинство ссылок открывается (только несколько выдают 404)

Информация ниже не помогла мне:

https://www.drupal.org/docs/7/configuring-clean-urls/enable-clean-urls

Я использую: PHP 5.4.45, nginx / 1.14.0

Спасибо за помощь.

Комментарии

Аватар пользователя bsc-man bsc-man 10 октября 2018 в 14:26

Если есть возможность глянуть, буду благодарен.
Конфигурационный файл two.com

server {
        server_name two.com www.two.com;
        charset UTF-8;
        index index.php index.html index.htm;
        disable_symlinks if_not_owner from=$root_path;
        include /etc/nginx/vhosts-includes/*.conf;
        include /etc/nginx/vhosts-resources/two.com/*.conf;
        access_log /var/www/httpd-logs/two.com.access.log;
        error_log /var/www/httpd-logs/two.com.error.log notice;
        ssi on;
        set $root_path /var/www/www-admin/data/www/one.by;
        root $root_path;
        gzip on;
        gzip_comp_level 6;
        gzip_disable "msie6";
        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
        if ( $host = www.two.com ){
                return 301 http://two.com$request_uri;
        }
        location / {
            try_files $uri $uri/ /index.php?q=$uri&$args;
                location ~ [^/]\.ph(p\d*|tml)$ {
                        try_files /does_not_exists @php;
                }
        }
        location @php {
                fastcgi_index index.php;
                fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f admin@one.com";
                fastcgi_pass unix:/var/www/php-fpm/www-admin.sock;
                fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
                try_files $uri =404;
                include fastcgi_params;
                set $no_cache "";
                if ($request_method !~ ^(GET|HEAD)$) {
                        set $no_cache "1";
                }
                if ($no_cache = "1") {
                        add_header Set-Cookie "_mcnc=1; Max-Age=2; Path=/";
                        add_header X-Microcachable "0";
                }
                if ($http_cookie ~ SESS) { #checks an auth'd user
                        set $no_cache "1";
                }
        }
        listen x.x.x.x:80;
}
server {
        server_name two.com www.two.com;
        ssl_certificate "/var/www/httpd-cert/www-admin/two.com_le1.crtca";
        ssl_certificate_key "/var/www/httpd-cert/www-admin/two.com_le1.key";
        ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
        ssl_prefer_server_ciphers on;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        add_header Strict-Transport-Security "max-age=31536000;";
        ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
        charset UTF-8;
        index index.php index.html index.htm;
        disable_symlinks if_not_owner from=$root_path;
        include /etc/nginx/vhosts-includes/*.conf;
        include /etc/nginx/vhosts-resources/two.com/*.conf;
        access_log /var/www/httpd-logs/two.com.access.log;
        error_log /var/www/httpd-logs/two.com.error.log notice;
        ssi on;
        set $root_path /var/www/www-admin/data/www/one.by;
        root $root_path;
        gzip on;
        gzip_comp_level 6;
        gzip_disable "msie6";
        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
        location / {
                location ~ [^/]\.ph(p\d*|tml)$ {
                        try_files /does_not_exists @php;
                }
        }
        location @php {
                fastcgi_index index.php;
                fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f admin@one.com";
                fastcgi_pass unix:/var/www/php-fpm/www-admin.sock;
                fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
                try_files $uri =404;
                include fastcgi_params;
        }
        listen x.x.x.x:443 ssl http2;
}
Аватар пользователя adano adano 10 октября 2018 в 15:49

Не вижу, где 443:

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

и

location ~* ^/.well-known/ {
  allow all;
}

и, имхо, отправляйте все http и www сразу на
return 301 https://

P.S. Впервые подобный конфиг вижу. Такое ощущение, что из каких-то первых версий nginx.

Аватар пользователя bsc-man bsc-man 11 октября 2018 в 16:09

Это прописано в файлике и подключается через
include /etc/nginx/vhosts-includes/*.conf;

location ^~ /.well-known/acme-challenge/ {
        alias /usr/local/mgr5/www/letsencrypt/;
}

По поводу перенаправлений - потом в итоге так и надо будет сделать, но сайт уже в работе и пока https лагает - не перенаправляю.