-1

I want to connect my SocketIO Client with the Backend. But if i use my Caddy File the Connection fails:

Caddyfile:

www.XXX.XXX:443 {
    tls XXX.XXX@XXX.de
    root * /srv
    route {
        reverse_proxy /api* api-server:8443
        try_files {path} {path}/ /index.html
        file_server
    }
}

Client:

socketRef.current = io.connect("https://www.XXX.XXX/api", {
      rejectUnauthorized: false,
      transports: ["websocket"],
    });
SilasUe
  • 9
  • 2

1 Answers1

0

https://socket.io/docs/v4/reverse-proxy/#caddy-2

try

handle /path/* {
    uri strip_prefix /path
    rewrite * /socket.io{path}
    reverse_proxy localhost:6969 {
        header_up Host {host}
        header_up X-Real-IP {remote}
    }
}
puz_zle
  • 459
  • 5
  • 7