<VirtualHost *:80>
    ServerName cours.alainnguyenduc.info

    Alias /.well-known/acme-challenge/ /var/www/certbot/.well-known/acme-challenge/
    <Directory "/var/www/certbot/.well-known/acme-challenge/">
        AllowOverride None
        Options None
        Require all granted
    </Directory>

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
    RewriteRule ^ https://alainnguyenduc.info%{REQUEST_URI} [R=301,L]
</VirtualHost>

<VirtualHost *:443>
    ServerName cours.alainnguyenduc.info

    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/alainnguyenduc.info/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/alainnguyenduc.info/privkey.pem

    Redirect permanent / https://alainnguyenduc.info/
</VirtualHost>



<VirtualHost *:80>
    ServerName alainnguyenduc.info
    ServerAlias www.alainnguyenduc.info

    DocumentRoot /var/www/html

    Alias /.well-known/acme-challenge/ /var/www/certbot/.well-known/acme-challenge/
    <Directory "/var/www/certbot/.well-known/acme-challenge/">
        AllowOverride None
        Options None
        Require all granted
    </Directory>

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</VirtualHost>

<VirtualHost *:443>
    ServerName alainnguyenduc.info
    ServerAlias www.alainnguyenduc.info

    DocumentRoot /var/www/html

    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/alainnguyenduc.info/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/alainnguyenduc.info/privkey.pem

    <Directory "/var/www/html">
        AllowOverride All
        Require all granted
    </Directory>

    Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
    Header always set X-Content-Type-Options "nosniff"
    Header always set Permissions-Policy "geolocation=(), microphone=(), camera=()"
</VirtualHost>
