2

如何使用与交叉路由器通信的 caddy 设置反向代理?

我有一个带有交叉开关路由器的 docker,它在 localhost 8080 上侦听,我使用 caddy 作为反向代理。

在 Caddyfile 下方:

`0.0.0.0:80
 proxy /ws localhost:8080{
     proxy_header Connection {>Connection}
     proxy_heade Upgrade {>Upgrade}
 }
 header /ws {
     Upgrade "WebSoket"
     Connection "Upgrade"
 }`

当我尝试连接时,'tcpflow 8080' 什么也不返回。

在 chrome 的标题下方:

回复

HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Sec-Websocket-Accept: r/PdCQJibmcb5XrfVbnSXJMuf9g=
Sec-Websocket-Protocol: wamp.2.json
Server: Caddy
Server: Crossbar/0.11.1
Upgrade: WebSocket
X-Powered-By: AutobahnPython/0.10.9
Date: Tue, 09 Feb 2016 14:12:04 GMT

要求

GET ws://78.46.244.23/ws HTTP/1.1
Host: 78.46.244.23
Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
Origin: chrome://newtab
Sec-WebSocket-Version: 13
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTM 
   like Gecko) Chrome/48.0.2564.103 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4
Sec-WebSocket-Key: OaEUxWnqjZWyfLypeYxeXw==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
Sec-WebSocket-Protocol: wamp.2.json

框架下方:

[1,"realm1",{"roles":{"caller":{"features":{"caller_identification":true,"progressive_call_results":true}},"callee":{"features":{"progressive_call_results":true}},"publisher":{"features":{"subscriber_blackwhite_listing":true,"publisher_exclusion":true,"publisher_identification":true}},"subscriber":{"features":{"publisher_identification":true}}}}]

和控制台错误:

WebSocket connection to 'ws://78.46.244.23/ws' failed: Invalid frame header
4

1 回答 1

0

您的 Caddyfile 中有错字:

Upgrade "WebSoket"

于 2017-09-30T22:01:21.477 回答