Utworzenie wirtualnego hosta /etc/apache2/sites-available/000-default.conf
<VirtualHost 81.137.4.24:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html/example ServerName example.pl </VirtualHost>
Wygenerowanie certyfikatu LetsEncrypt
# apt-get install python-certbot-apache
# certbot certonly --webroot -w /var/www/html/example
-d example.pl
Włączenie SSL
# a2enmod ssl # a2enmod rewrite # a2ensite default-ssl # systemctl reload apache2
Wpis dla wirtualnego hosta z certyfikatem certbot
<VirtualHost 81.137.4.24:443> ServerAdmin webmaster@localhost ServerName example.pl:443 DocumentRoot /var/www/html/example SSLEngine on SSLCertificateFile /etc/letsencrypt/live/example.pl/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.pl/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/example.pl/chain.pem </VirtualHost>
Konfiguracja modr_ewrite: /etc/apache2/apache2.conf
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
lub w pojemniku wirtualnego hosta
<VirtualHost *:80>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
. . .
</VirtualHost>
.htaccess – wymuszenie ssl
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]