Переадресация на веб-сервере nginx на https
Есть файл конфигурации для nginx.
server {
listen some_IP:80;
listen some_IP:443 ssl;
server_name domain.ru *.domain.ru;
root /some_path;
if ($host ~* www\.(.*)) {
set $host_without_www $1;
rewrite ^(.*)$ https://$host_without_www$1 permanent;
}
if ($scheme = http ) {
return 301 https://$host$request_uri;
}
ssl_certificate /etc/ssl/alaniagovru.crt;
ssl_certificate_key /etc/ssl/privatekey.key;
}
Есть несколько сайтов domain.ru, subdomain1.domain.ru, subdomain2.domain.ru итд. Необходимо настроить файл конфигурации nginx так, чтобы происходила переадресация с
subdomain.domain.ru/some_path,
www.subdomain.domain.ru/some_path,
http://subdomain.domain.ru/some_path,
http://www.subdomain.domain.ru/some_path,
https://www.subdomain.domain.ru/some_path
на https://subdomain.domain.ru/some_path.
и тоже самое для domain
domain.ru/some_path
www.domain.ru/some_path
http://domain.ru/some_path,
http://www.domain.ru/some_path,
https://www.domain.ru/some_path
на https://domain.ru/some_path.
Но с текущей конфигурацией отрабатывает переход с http на https, если же в адресной строке добавляется www, то перенаправление происходит на https://www.domain.ru или https://www.subdomain.domain.ru и содержимое страницы не открывается.