Skip to content

dstack-ingress: add WebSocket proxy support #87

@h4x3rotab

Description

@h4x3rotab

The kvin/dstack-ingress:wildcard image generates its nginx config via setup_nginx_conf() in the entrypoint, but the location / block is missing WebSocket upgrade headers. Without these, any WebSocket service behind dstack-ingress gets HTTP 200 instead of 101 Upgrade.

Suggested fix: add these three lines to the location / block in setup_nginx_conf():

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

This is safe for mixed HTTP + WebSocket traffic. $http_upgrade is empty for regular HTTP requests, and upstreams ignore Connection: upgrade when there's no valid Upgrade value. proxy_http_version 1.1 is strictly better than the default 1.0 (also enables keepalive). This is the standard nginx pattern recommended in the nginx WebSocket docs.

Current workaround: override command in docker-compose to patch the generated config before starting nginx:

command:
  - bash
  - -c
  - |
    sed -i '/proxy_pass/a\        proxy_http_version 1.1;\n        proxy_set_header Upgrade $$http_upgrade;\n        proxy_set_header Connection "upgrade";' /etc/nginx/conf.d/default.conf
    exec nginx -g "daemon off;"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions