Так что я пытаюсь получить https на моем VPS с помощью Certbot. Теперь у меня есть 2 сайта в моей папке с включенными сайтами (исключая 000-default.conf и default-ssl.conf и phpmyadmin.conf)
Итак, допустим, у меня есть test1.conf и test2.conf, я Я пытаюсь получить HTTPS для test1. Теперь aerntant certbot установил сертификат и все прошло без ошибок. Когда я пытаюсь получить доступ к test1.com, он дает мне ERR_SSL_PROTOCOL_ERROR. Я не могу понять, почему, поэтому я попытался поместить test1.conf в 000-default.conf, и это работает ?! Почему apache использует 000-default.conf и пропускает test1.conf?!
Я просто использую по умолчанию 000-default.conf, никогда не менял его. Это выглядит следующим образом:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Certbot создал дополнительный файл конфигурации с именем site1-le-ssl.conf. Это копия site1.conf, но включающая сертификат, поэтому я просто удалил site1.conf.
Теперь эта настройка выдает ошибку, поэтому я попытался добавить порт 443 к 000-default.conf, и я просто добавил сертификат и путь для site1 к 000-default.conf, и тогда это работает! Но конечно, site2 больше не работает. Новый 000-default.conf выглядит следующим образом:
<VirtualHost *:80 *:443>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
# DocumentRoot /var/www/html
DocumentRoot /var/www/site1
ServerName site1.com
ServerAlias www.site1.com
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/site1.com-0002/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/site1.com-0002/privkey.pem
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Как я могу заставить ssl / https работать только с отдельными файлами конфигурации? Так что я могу использовать test1.conf с https и test2.conf без https