server {
    listen 80;
    server_name {{ DISCOVERY_HOST }};

    server_tokens off;
    location / {
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Port $server_port;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://localhost:{{ NGINX_HTTP_PORT }};
    }
}
{% if ACTIVATE_HTTPS %}
server {
    listen 443 ssl;
    server_name {{ DISCOVERY_HOST }};

    ssl_certificate /etc/letsencrypt/live/{{ DISCOVERY_HOST }}/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/{{ DISCOVERY_HOST }}/privkey.pem;

    server_tokens off;
    location / {
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Port $server_port;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://localhost:{{ NGINX_HTTPS_PORT }};
    }
}
{% endif %}