Configure SSL/HTTPS on Apache2 with OpenSSL on localhost/docker/vm etc.

sudo apt-get update
sudo apt-get install -y openssl
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/certs/privkey.pem -out /etc/ssl/certs/fullchain.pem -subj "/C=PL/ST=mazowieckie/L=Warszawa/O=NAZWA FIRMY/OU=NAZWA JEDNOSTKI/CN=localhost"
sudo a2enmod ssl

Add to 000-default.conf

<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    # ProxyPassMatch ^/(.*\.php)$ fcgi://php:9000/var/www/html/$1 # If we use FPM

    SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/fullchain.pem
    SSLCertificateKeyFile /etc/apache2/ssl/privkey.pem

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>