Skip to content

Instantly share code, notes, and snippets.

@edrex
Created March 21, 2016 20:22
Show Gist options
  • Select an option

  • Save edrex/7af8da336fbd1ec6a2f9 to your computer and use it in GitHub Desktop.

Select an option

Save edrex/7af8da336fbd1ec6a2f9 to your computer and use it in GitHub Desktop.
localhost:2020 {
log proxy.log
proxy /echo localhost:2021 {
websocket
}
}
localhost:2021 {
log websocket.log
websocket /echo cat
}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
</head>
<body>
<script>
function testEchoSocket(path) {
var s = new WebSocket('ws://'+location.hostname+':'+location.port + path);
s.onmessage = function (event) {
console.log(event.data);
}
s.onopen = function (event) {
s.send("ohai");
}
}
testEchoSocket('/echo');
</script>
</body>
</html>
@edrex
Copy link
Author

edrex commented Mar 21, 2016

Connect to http://localhost:2020/ to test proxying to caddy websocket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment