map $http_x_forwarded_proto $real_proto {{
    ext+onions  ext+onions;
    ext+onion   ext+onion;
    https       https;
    http        http;
    default     $scheme;
}}
server {{
    listen 443 ssl;
    server_name {hostname}.local;
    ssl_certificate /root/appmgr/apps/{app_id}/cert-local.fullchain.crt.pem;
    ssl_certificate_key /root/appmgr/apps/{app_id}/cert-local.key.pem;
    location / {{
        proxy_pass http://{app_ip}:{internal_port}/;
        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-Proto $real_proto;
        client_max_body_size 0;
        proxy_request_buffering off;
        proxy_buffering off;
    }}
}}
server {{
    listen 80;
    server_name {hostname}.local;
    return 301 https://$host$request_uri;
}}
