4. enable ssl

Create SSL

sudo mkdir -p /data/cert
sudo chown -R $USER.$USER /data/cert
mv create_self-signed-cert.sh /data/cert
pushd /data/cert/ >/dev/null

domain_name=test.icinga.com
domain_ip="10.0.0.100"

bash create_self-signed-cert.sh --ssl-domain=${domain_name} \
--ssl-trusted-ip=${domain_ip} --ssl-size=4096 --ssl-date=3650

popd >/dev/null

apache2 enable ssl

sudo ln -snf /etc/apache2/sites-available/default-ssl.conf /etc/apache2/sites-enabled/000-default-ssl.conf

ssl conf

sudo tee /etc/apache2/sites-available/default-ssl.conf <<'EOF'
<IfModule mod_ssl.c>
  <VirtualHost _default_:443>
    ServerAdmin test@foxmail.com
    DocumentRoot /var/www/html
    ServerName test.icinga.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    SSLEngine on
    SSLCertificateFile /data/cert/test.icinga.com.crt
    SSLCertificateKeyFile /data/cert/test.icinga.com.key
    #SSLCertificateChainFile /etc/ssl/certs/ca.crt
    <FilesMatch "\.(cgi|shtml|phtml|php)$">
        SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory /usr/lib/cgi-bin>
        SSLOptions +StdEnvVars
    </Directory>
    </VirtualHost>
</IfModule>
EOF

load ssl module

sudo a2enmod ssl
sudo service apache2 restart

Rewrite

sudo tee /etc/apache2/sites-available/000-default.conf <<'EOF'
<VirtualHost *:80>
    RewriteEngine on
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*) https://%{SERVER_NAME}$1 [L,R]
    ServerAdmin test@foxmail.com
    DocumentRoot /var/www/html
    ServerName test.icinga.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
EOF

# Restart apache2
sudo a2enmod rewrite
sudo service apache2 restart

4 posts were merged into an existing topic: Icinga 2 Installation Guide