server {
    if ($host = kymoz.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
        listen 10080; 
        server_name msp.kymoz.com;
        rewrite ^(.*)$ https://${server_name}$1 permanent;
}
server {
    listen 10443 ssl;
    autoindex on;
    client_max_body_size 20m;
    server_name msp.kymoz.com;
    ssl_certificate /etc/letsencrypt/live/kymoz.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/kymoz.com/privkey.pem; # managed by Certbot

    proxy_set_header X-Forwarded-Host   $host;
    proxy_set_header X-Forwarded-server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Scheme $scheme;
    proxy_set_header X-Forwarded-Port    $server_port;
    proxy_set_header X-Forwarded-Url     "$scheme://$host:$server_port$request_uri";

    index index.html index.htm;
    proxy_buffering off;
    location ~^/ip$ {
        return 200 "$remote_addr";
    }

    location /wss/ {
        proxy_pass http://localhost:10101/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        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 $scheme;
        proxy_set_header X-Forwarded-Prepath 'wss';
    }
    location / {
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Origin *;
        proxy_set_header X-Forwarded-Host   $host;
        proxy_set_header X-Forwarded-server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Scheme $scheme;
        proxy_set_header X-Forwarded-Port    $server_port;
        proxy_set_header X-real-ip $remote_addr;
        proxy_send_timeout  600s;
        proxy_read_timeout      600s;
        proxy_pass http://localhost:10100/;
    }
}


