https://kamaok.org.ua/?p=672
1.Установка необходимых пакетов
1
|
# yum install openssl mod_ssl
|
2. Генерирование сертификатов
mkdir /etc/httpd/ssl
cd /etc/httpd/ssl
Для вирт.хоста kamaok.org.uaДля вирт.хоста по умолчанию
1
|
# openssl req -new -x509 -days 3650 -nodes -out cert.perm -keyout cert.key
|
1
|
# openssl req -new -x509 -days 3650 -nodes -out kamaok.org.ua.perm -keyout kamaok.org.ua.key
|
3. Настройка вирт.хоста по умолчанию
1
|
# nano /etc/httpd/conf.d/000default.conf
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
<VirtualHost *:443>
DocumentRoot /var/www/html
ServerName localhost
SSLEngine on
SSLCertificateFile /etc/httpd/ssl/cert.perm
SSLCertificateKeyFile /etc/httpd/ssl/cert.key
<Directory "/var/www/html">
Options -Indexes
AllowOverride all
Allow from all
</Directory>
ErrorLog logs/default-ssl-error.log
#ErrorLog /dev/null
CustomLog logs/default-ssl-access.log combined
#CustomLog /dev/null combined
</VirtualHost>
|
4.Настройка вирт.хоста kamaok.org.ua
1
|
# nano /etc/httpd/conf.d/kamaok.org.ua.conf
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
<VirtualHost *:443>
DocumentRoot /path/to/documentroot
ServerName kamaok.org.ua
ServerAlias *.kamaok.org.ua
SSLEngine on
SSLCertificateFile /etc/httpd/ssl/kamaok.org.ua.perm
SSLCertificateKeyFile /etc/httpd/ssl/kamaok.org.ua.key
<Directory "/path/to/documentroot">
Options -Indexes
AllowOverride all
Allow from all
</Directory>
ErrorLog logs/kamaok.org.ua-ssl-error.log
#ErrorLog /dev/null
CustomLog logs/kamaok.org.ua-ssl-access.log combined
#CustomLog /dev/null combined
</VirtualHost>
|
5. Включаем вирт.хостинг для https подключений
1
|
# nano /etc/httpd/conf/httpd.conf
|
6.Отключаем вирт.хост по умолчанию,который активируется при установке модуля mod_ssl
1
|
# cp /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ssl.conf~
|
1
|
# cat /etc/httpd/conf.d/ssl.conf | grep -v \# | grep -v ^$
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
LoadModule ssl_module modules/mod_ssl.so
Listen 443
SSLPassPhraseDialog builtin
SSLSessionCache shmcb:/var/cache/mod_ssl/scache(512000)
SSLSessionCacheTimeout 300
SSLMutex default
SSLRandomSeed startup file:/dev/urandom 256
SSLRandomSeed connect builtin
SSLCryptoDevice builtin
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
|
1
|
# /etc/init.d/httpd restart
|
Для принудительного перенаправления с http на https добавляем в описание вирт.хоста
либо в .htacccess в корень сайта.
1
2
3
|
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
|