petebytes
(petebytes)
November 13, 2019, 8:05pm
1
1. My Caddy version (caddy -version
):
v2.0.0-beta9
2. How I run Caddy:
nohup ./caddy &
exit
a. System environment:
Ubuntu 18.04
d. My complete Caddyfile:
tunnel.mysite.com {
reverse_proxy * localhost:8080 {
websocket
header_up Host {http.request.host}
header_up X-Real-IP {http.request.remote}
header_up X-Forwarded-For {http.request.remote}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
}
}
3. The problem I’m having:
When I try to start caddy I see “unrecognized subdirective websocket”
For reference, I am implementing caddy per this post https://blog.alexellis.io/https-inlets-local-endpoints/ and converting from Caddy 1.x to 2.x
Thank you
Hi @petebytes , welcome to the Caddy community!
Caddy v2’s reverse proxy doesn’t have a websocket
subdirective.
In Caddy v1, the websocket
preset configures two upstream headers, Connection
and Upgrade
.
You will need to specify these headers manually using request header placeholders (i.e. {http.request.header.FIELD-NAME}
) and the header_up
subdirective for v2’s reverse_proxy
.
https://caddyserver.com/v1/docs/proxy#presets
Home · caddyserver/caddy Wiki · GitHub
Home · caddyserver/caddy Wiki · GitHub
petebytes
(petebytes)
November 14, 2019, 12:49am
3
Thanks for the quick reply! Here is what I ended up with.
tunnel.mysite.com {
reverse_proxy * localhost:8080 {
header_up Host {http.request.host}
header_up X-Real-IP {http.request.remote}
header_up X-Forwarded-For {http.request.remote}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
header_up Connection {http.request.header.Connection}
header_up Upgrade {http.request.header.Upgrade}
}
}
1 Like
matt
(Matt Holt)
November 14, 2019, 3:04am
4
Websockets should work with v2’s reverse proxy by default. @petebytes If you remove these lines:
header_up Connection {http.request.header.Connection}
header_up Upgrade {http.request.header.Upgrade}
Does it still work for you?
matt
(Matt Holt)
November 14, 2019, 4:58am
6
Great!
To clarify, in v2, you do not need to do anything to enable websockets.
1 Like
system
(system)
Closed
February 12, 2020, 4:58am
7
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.