У меня есть два VirtualHost на одном Apache, один 000-default.conf и один site.conf. На site.conf включен SSL и подключен сертификат. Если из браузера обращаться по https://site.com, то открывается хост site.com, если по http, то аналогично, там стоит редирект на https. Если обращаться http://ip, то открывается 000-default, но если по https://ip, то открывается site.com с предупреждением о небезопасном соединении, поскольку сертификат привязан к IP. Как сделать чтобы при обращении к https://ip открывался 000-default или шел редирект на http?
Конфиги:
000-default:
<VirtualHost ip.ip.ip.ip:80>
ServerName ip.ip.ip.ip
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
site.com:
<VirtualHost site.com:443>
ServerName site.com
ServerAdmin webmaster@localhost
DocumentRoot /home/site/www
SSLEngine on
SSLProtocol all -SSLv2
SSLCertificateFile /path/to/ssl_certs/cert.crt
SSLCertificateKeyFile /path/to/ssl_certs/key.key
SSLCertificateChainFile /path/to/ssl_certs/chainfile.crt
ErrorLog /home/site/error.log
CustomLog /home/site/access.log combined
<Directory /home/site/www>
AllowOverride All
Require all granted
</Directory>
<IfModule mpm_itk_module>
AssignUserId user group
</IfModule>
</VirtualHost>
<VirtualHost site.com:80>
ServerName site.com
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>