I have this situation:
I have EV SSL and it's common name is abc.com
www.example.com is included on SAN's but not example.com
this is my vhost config:
server {
listen 80;
server_name example.com;
return 301 https://www.example.com$request_uri;
}
server {
listen 443 ssl http2 default_server;
ssl_certificate /etc/ssl/example/combined.crt;
ssl_certificate_key /etc/ssl/example/example.key;
root /var/www/example;
include snippets/ssl-params.conf;
add_header X-Frame-Options SAMEORIGIN;
location ~* \.(eot|ttf|woff)$ {
add_header Access-Control-Allow-Origin *;
}
location / {
index index.html index.php;
try_files $uri $uri/ @handler;
expires 30d; ## Assume all files are cachable
}
## These locations would be hidden by .htaccess normally
location ^~ /app/ { deny all; }
location ^~ /includes/ { deny all; }
location ^~ /lib/ { deny all; }
location ^~ /media/downloadable/ { deny all; }
location ^~ /pkginfo/ { deny all; }
location ^~ /report/config.xml { deny all; }
location ^~ /var/ { deny all; }
location /var/export/ { ## Allow admins only to view export folder
auth_basic "Restricted"; ## Message shown in login window
auth_basic_user_file /root/htpasswd; ## See /etc/nginx/htpassword
autoindex on;
}
location /. { ## Disable .htaccess and other hidden files
return 404;
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}
location ~ .php$ { ## Execute PHP scripts
if (!-e $request_filename) { rewrite / /index.php last; }
#fastcgi_param MAGE_IS_DEVELOPER_MODE on;
expires off; ## Do not cache dynamic content
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_param HTTPS $fastcgi_https;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE default;
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params; ## See /etc/nginx/fastcgi_params
}
}
My issue is I can't seem to make it redirect from http://example.com to https://www.example.com
NOTE: when I try example.com on ssl checker it says
The hostname (example.com) does NOT match the Common Name in the certificate (abc.com). This certificate is currently invalid for this host.