Sorry for my typo on {~ AppSession} , i actually abbreviated it to post here.
The /wi_studio/foo/bar did not work, however I tried another workaround based on the post Proxy/Rewrite Priority. It allowed the /wistudio proxy to work.
my caddy file looks like this now: -
Blockquote
0.0.0.0:{$CADDY_PROXY_PORT} {
gzip
root {$DATA_DIR}/proxy
log / stdout "{combined} UPSTREAM: {upstream} REWRITE: {rewrite_uri} TOKEN: {>X-App-Token} COOKIE:{~AppSession}"
# CORS allow all
# cors /
# Re-write / to /login if X-App-Token does not exist
rewrite {
if {>X-App-Token} is ""
if {path} is /
to /login{uri}
}
rewrite {
regexp ^/wistudio/.*$
to /wi_studio{uri}
}
# Re-write / to /web_server
rewrite {
#regexp ^/.*$
to /web_server{uri}
}
proxy /login {$LOGIN_SERVICE} {
# Set downstream header cookie
header_downstream X-App-Token {~AppSession}
header_upstream X-App-Token {~AppSession}
without /login
}
# Proxy /web_server and remove proxy prefix since
# it is the /
proxy /web_server {$WEB_SERVICE} {
#transparent
without /web_server
except /wistudio
# Set upstream+downstream header cookie
header_upstream X-App-Token {~AppSession}
header_downstream X-App-Token {~AppSession}
}
}
# Proxy /wistudio
0.0.0.0:{$CADDY_PROXY_PORT}/wistudio {
proxy / {$WISTUDIO_SERVICE} {
transparent
# without /wi_studio
# Set upstream header cookie
header_upstream X-App-Token {~AppSession}
header_downstream X-App-Token {~AppSession}
}
}