I want to make a docker container in which a reverse proxy to all applications will be performed using caddy. Unfortunately, everything is simple, I use the following code in caddyfile:
rewrite /tools/vscode /tools/vscode/
handle_path /tools/vscode/* {
reverse_proxy localhost:8091 #port of vscode in docker container
}
However, I can dynamically launch many other applications from within and constantly rebuilding docker is not the best option. How can I forward connections from /tools/port/path to localhost:port/path using caddy?
I tried using regular expression:
@tools path_regexp tools ^/tools2/(\d+)/(.*)$
handle @tools {
reverse_proxy localhost:{re.tools.1}/{re.tools.2}
}
but it didn't help and gives an error when I switch to /tools2/8091/test 502 Bad Gateway dial localhost:8091: unknown network localhost:8091 reverseproxy.statusError (reverseproxy.go:1299) 2p9m1w12a