server {
    server_name {{ monica_domain }};

    listen 80;
    listen [::]:80;

    location / {
      return https://$server_name$request_uri;
    }
}


server {
    server_name {{ monica_domain }};

    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    ssl_trusted_certificate   /etc/letsencrypt/live/{{ monica_domain }}/chain.pem;
    ssl_certificate           /etc/letsencrypt/live/{{ monica_domain }}/fullchain.pem;
    ssl_certificate_key       /etc/letsencrypt/live/{{ monica_domain }}/privkey.pem;

    ssl_stapling on;
    ssl_stapling_verify on;

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    client_max_body_size 10m;

    location / {
        proxy_pass http://127.0.0.1:8080;
    }
}