I'm trying to configure caddy and socket.io

1. I’m trying to configure caddy and socket.io:

Hello! :waving_hand:
I have a configuration problem on my server with caddy file. I try to setup socket.io and caddy only, when I put the direct ip ([ip]:3030) of my server, the socket setup correctly. but when i go through my domain ([domain]/socket.io) and try to setup the socket I get a code 200 but no connection log from my socket. :sob:

Do you have any idea how to solve the problem? (I looked at the post: I can't get socket.io proxy to work on v2 - #2 by francislavoie but it doesn’t change anything)

Thank you in advance for your reply and sorry for the inconvenience. :blue_heart:

2. I don’t get any error message, I have a code 200:

image_2024-09-01_021356036

3. Caddy version:

→ 2.6.2

4. My caddy config:

My complete Caddy config:

<domain>, www.<domain> {

        handle /api/ {
                reverse_proxy localhost:3030
        }

        handle_path /api/* {
                reverse_proxy localhost:3030
        }

        #-------------------------------------------

        handle /* {
                reverse_proxy localhost:3000
        }


        #------------------------------------------


        handle /socket.io/* {
                reverse_proxy localhost:3030
        }

}

Howdy @Col0x, welcome to the Caddy community.

Firstly,

This version is two years out of date, and we recommend upgrading to the latest version, which is v2.8.4 as of this comment. Releases · caddyserver/caddy · GitHub

There’s some more information we’d like to see to help troubleshoot the issue.

From our Help topic template:

  • We want to help you, but if you ignore or skip questions in this template, we will just ask you to fill it out anyway.

2. Error messages and/or full log output:

Please ENABLE DEBUG MODE FIRST by adding “debug” to the global options of your Caddyfile. See Global options (Caddyfile) — Caddy Documentation for an example.

4. How I installed and ran Caddy:

a. System environment:

OS, architecture, relevant versions, systemd? Docker? etc.

b. Command:

Commands are what you type into a terminal, i.e. the command you use to run Caddy.
Please read Keep Caddy Running — Caddy Documentation to understand the recommended commands to run Caddy, depending on your installation method.

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

c. Service/unit/compose file:

If using Docker/systemd/Kubernetes/make etc.
Delete the code block below if not relevant.

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

The debug messages in particular might be useful, as will the particulars of how you installed and ran Caddy.

Ok here’s the solution i found:

<host> {
reverse_proxy /socket.io/* localhost:3030 {
		header_up Host {host}
		header_up X-Real-IP {remote}
		header_up X-Forwarded-For {remote}
		header_up X-Forwarded-Proto {scheme}
	}
}

Remove all this. It’s not useful. See the docs: