upstream garm_backend {
    server 192.168.122.100:9997       weight=5;
}

server {
    server_name garm.example.com;

    location /api/v1/ws {
        proxy_pass http://garm_backend;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
    }

    location / {
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Host $http_host;

        proxy_pass http://garm_backend;
        proxy_set_header        Host    $Host;
        proxy_redirect off;
    }

    listen 443 ssl; 
    ssl_certificate /etc/nginx/ssl/fullchain.pem;
    ssl_certificate_key /etc/nginx/ssl/privkey.pem;
}

server {
    if ($host = garm.example.com) {
        return 301 https://$host$request_uri;
    }

    server_name garm.example.com;
    listen 80;
    return 404;
}
