I got the NTLM bits disabled, so not I am just doing a plain reverse_proxy setup, though it is not working. Static resources from the remote server loads fine, but websockets do not work.
1. The problem I’m having:
I am setting up a reverse proxy with Caddy to allow a legacy client access an web application on another server. The problem I am facing is an http status 500 for websocket requests.
2. Error messages and/or full log output:
Chrome shows this error in the webtools console:
WebSocket connection to 'ws://my-caddy-server.com:9991/system/pws/Andon_DX/253f4d88?token=Z6jj_b_9psYIt7lSJDsxtWN74e1Y4mAVO3RNOW1JuWc' failed: Error during WebSocket handshake: Unexpected response code: 500
Caddy logs show many rows like this:
{
"level": "info",
"ts": 1708949045.1448529,
"logger": "http.log.access.log0",
"msg": "handled request",
"request": {
"remote_ip": "10.12.143.250",
"remote_port": "61285",
"client_ip": "10.12.143.250",
"proto": "HTTP/1.1",
"method": "GET",
"host": "my-caddy-server.com:9991",
"uri": "/data/perspective/hello/Andon_DX/253f4d88",
"headers": {
"Accept-Language": [
"en-US,en;q=0.9"
],
"Connection": [
"keep-alive"
],
"Version-Code": [
"0"
],
"Accept": [
"application/json, text/plain, */*"
],
"Device-Id": [
"86db965b-57c3-48a6-9805-c5a4fd89ec9b"
],
"User-Agent": [
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.62"
],
"Referer": [
"http://my-caddy-server.com:9991/data/perspective/client/Andon_DX/disign"
],
"Device-Type": [
"browser"
],
"Client-Timezone": [
"Europe/Stockholm"
],
"Accept-Encoding": [
"gzip, deflate"
]
}
},
"bytes_read": 0,
"user_id": "",
"duration": 0.0037787,
"size": 588,
"status": 200,
"resp_headers": {
"Content-Length": [
"588"
],
"Date": [
"Mon, 26 Feb 2024 12:04:05 GMT"
],
"Referrer-Policy": [
"strict-origin-when-cross-origin"
],
"X-Content-Type-Options": [
"nosniff"
],
"Cache-Control": [
"no-cache, no-store"
],
"Content-Type": [
"application/json"
],
"Server": [
"Caddy"
],
"Expires": [
"Thu, 01 Jan 1970 00:00:00 GMT"
],
"X-Frame-Options": [
"SAMEORIGIN"
],
"X-Xss-Protection": [
"1; mode=block"
],
"Pragma": [
"no-cache"
],
"Set-Cookie": [
"JSESSIONID=node01vqzbicaejylo16dn80mynseu8616.node0; Path=/; Secure; HttpOnly"
]
}
}
{
"level": "error",
"ts": 1708949045.1563049,
"logger": "http.log.access.log0",
"msg": "handled request",
"request": {
"remote_ip": "10.12.143.250",
"remote_port": "62960",
"client_ip": "10.12.143.250",
"proto": "HTTP/1.1",
"method": "GET",
"host": "my-caddy-server.com:9991",
"uri": "/system/pws/Andon_DX/253f4d88?token=ONukfWtus3fmcTF_2ErxFNUlwKZrJbxM_dKTwDiy-E4",
"headers": {
"Connection": [
"Upgrade"
],
"Cache-Control": [
"no-cache"
],
"User-Agent": [
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.62"
],
"Upgrade": [
"websocket"
],
"Sec-Websocket-Version": [
"13"
],
"Sec-Websocket-Extensions": [
"permessage-deflate; client_max_window_bits"
],
"Origin": [
"http://my-caddy-server.com:9991"
],
"Accept-Encoding": [
"gzip, deflate"
],
"Accept-Language": [
"en-US,en;q=0.9"
],
"Sec-Websocket-Key": [
"gTko2CkUBXfW1BDQRZoKhw=="
],
"Pragma": [
"no-cache"
]
}
},
"bytes_read": 0,
"user_id": "",
"duration": 0.0075772,
"size": 357,
"status": 500,
"resp_headers": {
"Content-Length": [
"357"
],
"Referrer-Policy": [
"strict-origin-when-cross-origin"
],
"X-Content-Type-Options": [
"nosniff"
],
"X-Frame-Options": [
"SAMEORIGIN"
],
"Server": [
"Caddy"
],
"X-Xss-Protection": [
"1; mode=block"
],
"Cache-Control": [
"must-revalidate,no-cache,no-store"
],
"Content-Type": [
"text/html;charset=iso-8859-1"
]
}
}
3. Caddy version:
2.7.6
4. How I installed and ran Caddy:
Downloaded the Windows binary from GitHub.
a. System environment:
Windows 10 x64
b. Command:
C:\Caddy\caddy.exe start -c c:\Caddy\Caddyfile
d. My complete Caddy config:
#main
{
auto_https off
auto_https disable_redirects
log {
output file C:\Caddy\caddy.log {
roll_size 10M
}
}
servers {
log_credentials
}
}
http://my-caddy-server.com:9991 {
log {
format json
output file C:\Caddy\dxsrv11.log {
roll_size 10M
}
}
reverse_proxy https://upsteam-server:443 {
}
}
I’ve also tried setting header_up Host {upstream_hostport}
in the reverse_proxy section.