# TODO: replace <DOMAIN>, <EXTRA-DOMAINS>, and <DIRECTORY>.
# in vim use """:%s/<DIRECTORY>/replacement/g"""

server {
    listen 443 ssl http2 default_server;
    listen [::]:443 ssl http2 ipv6only=on default_server;

    ssl_certificate /etc/letsencrypt/live/<DOMAIN>/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/<DOMAIN>/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    root /var/www/<DIRECTORY>;

    index index.html index.php;

    server_name <DOMAIN> <EXTRA-DOMAINS>;

    server_tokens off; # prevent nginx server detection

    # restrict access to git folder
    location ~ /\.git {
        return 404;
    }

    # optional, enforce primary domain
    #if ($host != $server_name) {
    #    return 301 https://$server_name$request_uri;
    #}

    location / {
        try_files $uri $uri/ =404;
    }

    error_page 404 /404.html;

    access_log /var/log/nginx/<DOMAIN>.access.log tabbed_detailed;
}
server {
    listen 80 default_server;
    listen [::]:80 ipv6only=on default_server;

    server_name <DOMAIN> <EXTRA-DOMAINS>;

    server_tokens off; # prevent nginx server detection

    return 301 https://$server_name$request_uri;

    access_log /var/log/nginx/http.access.log tabbed_detailed;
}
