
map $http_upgrade $connection_upgrade {{
        default upgrade;
        '' $http_connection;
}}

server {{
        listen 443 ssl default_server;
        listen [::]:443 ssl default_server;
        ssl_certificate /etc/nginx/ssl/embassy_main.cert.pem;
        ssl_certificate_key /etc/nginx/ssl/embassy_main.key.pem;

        root /var/www/html/main;

        index index.html index.htm index.nginx-debian.html;

        server_name .{lan_hostname};

        proxy_buffering off;
        proxy_request_buffering off;
        proxy_socket_keepalive on;
        proxy_http_version 1.1;
        proxy_read_timeout 1800;

        gzip on;
        gzip_vary on;
        gzip_min_length 1024;
        gzip_types text/plain text/css text/xml text/javascript application/javascript image/svg+xml font/tts font/otf font/eot font/openttype application/x-javascript application/xml;


        location /rpc/ {{
                proxy_pass http://127.0.0.1:5959/;
        }}

        location /ws/ {{
                proxy_pass http://127.0.0.1:5960$request_uri;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade";
        }}

        location /rest/ {{
                proxy_pass http://127.0.0.1:5960$request_uri;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade";
                client_max_body_size 0;
        }}

        location /public/ {{
                proxy_pass http://127.0.0.1:5961/;
        }}

        location / {{
                try_files $uri $uri/ =404;
        }}
}}
server {{
    listen 80;
    listen [::]:80;
    server_name .{lan_hostname};
    return 301 https://$host$request_uri;
}}
server {{
        listen 80 default_server;
        listen [::]:80 default_server;
        ssl_certificate /etc/nginx/ssl/embassy_main.cert.pem;
        ssl_certificate_key /etc/nginx/ssl/embassy_main.key.pem;

        root /var/www/html/main;

        index index.html index.htm index.nginx-debian.html;

        server_name .{tor_hostname};

        proxy_buffering off;
        proxy_request_buffering off;
        proxy_socket_keepalive on;
        proxy_http_version 1.1;
        proxy_read_timeout 1800;

        gzip on;
        gzip_vary on;
        gzip_min_length 1024;
        gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;

        location /rpc/ {{
                proxy_pass http://127.0.0.1:5959/;
        }}

        location /ws/ {{
                proxy_pass http://127.0.0.1:5960$request_uri;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade";
        }}

        location /rest/ {{
                proxy_pass http://127.0.0.1:5960$request_uri;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade";
                client_max_body_size 0;
        }}

        location /public/ {{
                proxy_pass http://127.0.0.1:5961/;
        }}

        location / {{
                try_files $uri $uri/ =404;
        }}
}}
server {{
    listen 443 ssl;
    listen [::]:443;
    server_name .{tor_hostname};
    return 301 http://$host$request_uri;
}}