Получилось решить проблему примерно следующим конфигом:
site.com - онли хттпс
server {
listen 80 default_server;
server_name www.site.com site.com;
access_log /var/www/site.com/logs/nginx.access_log;
error_log /var/www/site.com/logs/nginx.error_log;
return 301 https://site.com$request_uri;
}
server {
listen 443 ssl;
server_name www.site.com;
access_log /var/www/site.com/logs/nginx.access_log;
error_log /var/www/site.com/logs/nginx.error_log;
ssl on;
ssl_certificate /etc/nginx/ssl/site.com.compiled.crt;
ssl_certificate_key /etc/nginx/ssl/site.com.key;
return 301 https://site.com$request_uri;
}
server {
listen 443 default_server ssl;
server_name site.com;
access_log /var/www/site.com/logs/nginx.access_log;
error_log /var/www/site.com/logs/nginx.error_log;
root /var/www/site.com/public_html;
index index.html index.htm;
ssl on;
ssl_certificate /etc/nginx/ssl/site.com.compiled.crt;
ssl_certificate_key /etc/nginx/ssl/site.com.key;
location / {
try_files $uri $uri/ =404;
fastcgi_param HTTPS on;
}
}
и второй, тестовый хост
server {
listen 443 ssl;
server_name www.dev.site.com dev.site.com;
access_log /var/www/dev.site.com/logs/nginx.access_log;
error_log /var/www/dev.site.com/logs/nginx.error_log;
return 301 http://dev.site.com$request_uri;
}
server {
listen 80;
server_name www.dev.site.com;
access_log /var/www/dev.site.com/logs/nginx.access_log;
error_log /var/www/dev.site.com/logs/nginx.error_log;
return 301 http://dev.site.com$request_uri;
}
server {
listen 80;
server_name dev.site.com;
access_log /var/www/dev.site.com/logs/nginx.access_log;
error_log /var/www/dev.site.com/logs/nginx.error_log;
root /var/www/dev.site.com/public_html;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
}