server {
    listen 80;
    server_name {{ LMS_HOST }} preview.{{ LMS_HOST }} {{ CMS_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 {{ LMS_HOST }} preview.{{ LMS_HOST }} {{ CMS_HOST }};

    ssl_certificate /etc/letsencrypt/live/{{ LMS_HOST }}/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/{{ LMS_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 %}

{{ patch("proxy-nginx") }}