Эта заметка представляет собой вольный перевод следующей статьи: http://blog.revolunet.com/index.php/reseau/administration/hosting-multiple-ssl-vhosts-on-a-single-ipportcertificate-with-apache2
Когда на работе решили сделать второй SSL-сайт, все почему-то поломалось. В частности, выскакивала вот такая ошибка:
SSL получило запись, длина которой превышает максимально допустимую.
(Код ошибки: ssl_error_rx_record_too_long)
Оказывается вот в чем причина. HTTPS – это SSL-туннель, по которому пущен HTTP. Виртуальные хосты для обычного HTTP работают следующим образом – когда браузер посылает запрос, веб-сервер проверяет его поле Host, и принимает решение, какую страничку показывать. Так вот, если взять HTTPS, то туннель создается до того, как будет послан первый HTTP-пакет, и сервер не знает, что именно показывать браузеру. В той статье приводится решение, основанное на mod_rewrite.
Нужно создать файл отображений доменных имен на каталоги, например так:
site1.domain.ru /var/www/site1/ site2.domain.ru /var/www/site2/
Далее, завести один и только один виртуальный хост для SSL-соединений:
NameVirtualHost *:443 LoadModule ssl_module modules/mod_ssl.so <VirtualHost *:443> SSLEngine on SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire SSLCertificateFile /etc/httpd/conf/ssl/cert.pem SSLCertificateKeyFile /etc/httpd/conf/ssl/cert.pem DirectoryIndex index.shtml index.html index.php index.htm ErrorLog logs/ssl-error.logs CustomLog logs/ssl-access.logs common Include conf/mass_ssl_vhosts.conf </VirtualHost>
В конце этого файлика подключен файл, реализующий rewrite-логику. Надо только не забыть в 8 строке поменять путь на свой файл ssl.map. Его можно скачать здесь:
http://blog.revolunet.com/wp-content/uploads/2008/01/mass_ssl_vhosts.conf
или отсюда скопировать:
### Mass SSL Vhosts ### RewriteEngine on # define two maps: one for fixing the URL and one which defines # the available virtual hosts with their corresponding # DocumentRoot. RewriteMap lowercase int:tolower RewriteMap vhost txt:/etc/apache2/ssl.map # 1. make sure we don't map for common locations RewriteCond %{REQUEST_URI} !^/cgi-bin/.* RewriteCond %{REQUEST_URI} !^/icons/.* # 2. make sure we have a Host header RewriteCond %{HTTP_HOST} !^$ # 3. lowercase the hostname RewriteCond ${lowercase:%{HTTP_HOST}|NONE} ^(.+)$ # # 4. lookup this hostname in vhost.map and # remember it only when it is a path # (and not "NONE" from above) RewriteCond ${vhost:%1} ^(/.*)$ # 5. finally we can map the URL to its docroot location # and remember the virtual host for logging puposes RewriteRule ^/(.*)$ %1/$1 [E=VHOST:${lowercase:%{HTTP_HOST}}]
I was suggested this web site by means of my cousin. I am
no longer sure whether this publish is written by him as nobody else recognize
such precise about my trouble. You are amazing!
Thanks!
Hi all, here every one is sharing such experience,
therefore it’s good to read this website, and I used to pay a quick visit this blog daily.
I don’t know whether it’s just me or if perhaps everyone else
experiencing problems with your website. It looks like some of
the written text on your posts are running off the screen. Can somebody else
please comment and let me know if this is happening to them as well?
This could be a problem with my browser because I’ve had this happen before.
Kudos
Piece of writing writing is also a fun, if you know then you can write if not
it is complicated to write.