Proxy from HTTP via NGINX

I’m using a cluster-in-a-box image and trying to connect to k8s clusters from a Nginx endpoint. I’ve managed to configure Nginx to work with Websockets, I think.

The idea is: I have a Nginx to connect to the Studio and the Cluster. When routing :80 to memsql:8080 works just fine. However, when to memsql:3306 it is not working.

Nginx config:

error_log /home/app/data/logs/error.log warn;

upstream webapp {
server memsql:8080;
}

upstream backend_host {
# enable sticky session based on IP
ip_hash;

server memsql:3306;

}
server {

access_log /home/app/data/logs/access.log;

listen 80;

location / {
    proxy_pass http://webapp;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_redirect off;
}

location @websocket {
    proxy_pass http://backend_host;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
}

}`

I’ve got these errors on /var/lib/singlestoredb-studio/studio.log when trying to add cluster to the studio:

Proxy error platform/studio/server.ProxyHandler.func2 /go/src/platform/studio/server/proxy.go:111 net/http.HandlerFunc.ServeHTTP /usr/local/go/src/net/http/server.go:2042 platform/vendor/github.com/gorilla/mux.(*Router).ServeHTTP /go/src/platform/vendor/github.com/gorilla/mux/mux.go:210 platform/vendor/github.com/rs/cors.(*Cors).Handler.func1 /go/src/platform/vendor/github.com/rs/cors/cors.go:200 net/http.HandlerFunc.ServeHTTP /usr/local/go/src/net/http/server.go:2042 platform/vendor/github.com/gorilla/handlers.loggingHandler.ServeHTTP /go/src/platform/vendor/github.com/gorilla/handlers/handlers.go:69 net/http.serverHandler.ServeHTTP /usr/local/go/src/net/http/server.go:2843 net/http.(*conn).serve /usr/local/go/src/net/http/server.go:1925 runtime.goexit /usr/local/go/src/runtime/asm_amd64.s:1374