events {
    worker_connections  1024;
}

http {
    server_tokens off;
    charset utf-8;

    server {
        listen 80 default_server;

        server_name _;

        location ~ /.well-known/acme-challenge/ {
            root /data/certbot-challenge;
        }

        location / {
            proxy_pass ${LACONIC_ORIGIN_SERVICE_URL};
        }
    }

    server {
        listen 443 ssl http2;
        ssl_certificate     /data/certificates/live/${LACONIC_TLS_DOMAIN}/fullchain.pem;
        ssl_certificate_key /data/certificates/live/${LACONIC_TLS_DOMAIN}/privkey.pem;
        server_name ${LACONIC_TLS_DOMAIN};
        root /var/www/html;
        index index.php index.html index.htm;

        location / {
            proxy_pass ${LACONIC_ORIGIN_SERVICE_URL};
        }

        location ~ /.well-known/acme-challenge/ {
            root /data/certbot-challenge;
        }
    }
}
