I’m currently configuring caddy and need to utilize multiple handle and handle path directives. I believe (haven’t tested yet) both of these work, but curious which is better (if one is better than the other)
Option 1: default handle, then paths nested inside with a catchall at the end:
http://{{ domain }}, https://{{ domain }} {
log {
output stdout
}
@websockets {
header Connection *Upgrade*
header Upgrade websocket
}
handle {
handle_path /rest* {
reverse_proxy 127.0.0.1:{{ rpc_port }} {
header_up Host localhost
}
}
handle_path /grpc* {
reverse_proxy 127.0.0.1:{{ rpc_port }} {
header_up Host localhost
}
}
handle /websocket {
reverse_proxy @websockets 127.0.0.1:{{ ws_port }} {
header_up Host localhost
}
}
handle {
reverse_proxy 127.0.0.1:{{ rpc_port }} {
header_up Host localhost
}
reverse_proxy @websockets 127.0.0.1:{{ ws_port }} {
header_up Host localhost
}
}
}
}
Option 2: individual handle/handle_paths and the catchall at the end:
http://{{ domain }}, https://{{ domain }} {
log {
output stdout
}
@websockets {
header Connection *Upgrade*
header Upgrade websocket
}
handle_path /rest* {
reverse_proxy 127.0.0.1:{{ rpc_port }} {
header_up Host localhost
}
}
handle_path /grpc* {
reverse_proxy 127.0.0.1:{{ rpc_port }} {
header_up Host localhost
}
}
handle /websocket {
reverse_proxy @websockets 127.0.0.1:{{ ws_port }} {
header_up Host localhost
}
}
handle {
reverse_proxy 127.0.0.1:{{ rpc_port }} {
header_up Host localhost
}
reverse_proxy @websockets 127.0.0.1:{{ ws_port }} {
header_up Host localhost
}
}
}