Редирект http to https (80 > 443). Nginx.
Здравствуйте.
Всем проектам на сервере подключены сертификаты и по https открываются корректно. Но выяснилось совсем недавно, что если жестко прописать http://site.com, то ничего не открывается, будто просто нет сайта по такому адресу. Даже http://www.redirect-checker.org ничего не выдает, даже ошибок.
Веб-сервер такой: Apache MPM-ITK 2.4.10-10+deb8u14, PHP module 5.6.40+dfsg-0+deb8u2, PHP-FPM 5.6.40+dfsg-0+deb8u2, awstats 7.2+dfsg-1+deb8u1, logrotate 3.8.7-1+b1, nginx 1.14.1-1~jessie
nginx.conf
user www-data;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
multi_accept on;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
keepalive_requests 100;
reset_timedout_connection on;
client_header_timeout 3;
client_body_timeout 5;
send_timeout 3;
client_header_buffer_size 2k;
client_body_buffer_size 256k;
access_log off;
# Cache
open_file_cache max=200000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
gzip_min_length 10;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;
ssl_prefer_server_ciphers on;
ssl_stapling on;
resolver 8.8.8.8;
fastcgi_buffer_size 32k;
fastcgi_buffers 256 4k;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/vhosts/*/*.conf;
client_max_body_size 128m;
}
Конфиг сайта (/etc/nginx/vhosts/basics-medicine/basics-medicine.com.conf)
server {
server_name basics-medicine.com *.basics-medicine.com www.basics-medicine.com;
ssl_certificate "/var/www/httpd-cert/basics-medicine/basics-medicine.com_le1.crtca";
ssl_certificate_key "/var/www/httpd-cert/basics-medicine/basics-medicine.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;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/basics-medicine.com/*.conf;
access_log /var/www/httpd-logs/basics-medicine.com.access.log;
error_log /var/www/httpd-logs/basics-medicine.com.error.log notice;
ssi on;
set $root_path /var/www/basics-medicine/data/www;
server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
keepalive_requests 100;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
gzip_min_length 10;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @php;
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
expires max;
}
}
location ~ /\. {
deny all;
}
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|swf)$ {
expires max;
log_not_found off;
}
location @php {
fastcgi_index index.php;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@basics-medicine.com";
fastcgi_pass unix:/var/www/php-fpm/basics-medicine.sock;
fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
fastcgi_param HTTPS on;
try_files $uri =404;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
include fastcgi_params;
}
if ($host ~* ^((.*).basics-medicine.com)$) {
set $subdomain $1;
}
root $root_path/$subdomain;
set $subdomain basics-medicine.com;
listen 212.80.218.72:443 ssl;
}
server {
listen 80;
server_name basics-medicine.com www.basics-medicine.com;
return 301 https://$host$request_uri;
}
nginx -t ошибок не выдает. Что интересно, curl -I как-будто правильный редирект отдает
curl -I basics-medicine.com
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Mon, 20 May 2019 07:17:46 GMT
Content-Type: text/html
Connection: keep-alive
Location: https://basics-medicine.com/
curl -I http://basics-medicine.com
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Mon, 20 May 2019 07:18:03 GMT
Content-Type: text/html
Connection: keep-alive
Location: https://basics-medicine.com/
Но по факту нихрена не работает.
Перелопатил первую 20-ку гугла на тему, ничего не помогает.