server {
    listen 80;
    listen [::]:80;
    server_name updates.example.com;

    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name updates.example.com;

    ssl_certificate /etc/letsencrypt/live/updates.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/updates.example.com/privkey.pem;

    client_max_body_size 1g;
    proxy_read_timeout 65s;
    proxy_send_timeout 65s;

    # Optional: restrict the admin UI to VPN or office IP ranges.
    # location /admin/ {
    #     allow 10.0.0.0/8;
    #     allow 192.168.0.0/16;
    #     allow 100.64.0.0/10;
    #     deny all;
    #
    #     proxy_pass http://127.0.0.1:8080;
    #     include /etc/nginx/snippets/update-server-proxy.conf;
    # }

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Proto https;
    }
}

