My requirement is to reverse proxy requests from the /ws_yk path to the service on port 8091 after removing the _yk suffix. Port 8091 is a Spring Boot application with an endpoint at the /ws path. The current issue is that direct access results in a 404 error. The logs are as follows.
here is my Caddyfile
:443 {
tls /data/certs/cert.pem /data/certs/key.pem
handle_path /api_yk/* {
reverse_proxy http://127.0.0.1:8091
}
handle /ws_yk/* {
uri path_regexp ws_yk ws
reverse_proxy http://127.0.0.1:8091
}
handle_path /oss_yk/* {
file_server {
root /var/lib/rms-yk
}
}
handle_path /api/* {
reverse_proxy http://127.0.0.1:8090
}
handle /ws/* {
reverse_proxy http://127.0.0.1:8090
}
handle_path /oss/* {
file_server {
root /var/lib/rms
}
}
file_server {
root /var/lib/rms/dist
}
}
When i send a wss connection request in postman like this wss://192.168.103.30/ws_yk/status
I got 404 error
Here is log of caddy when i sent the request:
{
"level": "debug",
"ts": 1723182660.7863111,
"logger": "http.handlers.rewrite",
"msg": "rewrote request",
"request": {
"remote_ip": "10.127.150.90",
"remote_port": "59202",
"client_ip": "10.127.150.90",
"proto": "HTTP/1.1",
"method": "GET",
"host": "192.168.103.30",
"uri": "/ws_yk/status?satoken=8cef785f53224ffebe828c5797163cfc",
"headers": {
"Sec-Websocket-Version": ["13"],
"Sec-Websocket-Key": ["6YP9Cd1hj31yZRCUV6111A=="],
"Connection": ["Upgrade"],
"Upgrade": ["websocket"],
"Sec-Websocket-Extensions": ["permessage-deflate; client_max_window_bits"]
},
"tls": {
"resumed": false,
"version": 772,
"cipher_suite": 4865,
"proto": "",
"server_name": ""
}
},
"method": "GET",
"uri": "/ws/status?satoken=8cef785f53224ffebe828c5797163cfc"
}
Any idea?
I hope to access my WS endpoint according to the above requirements.