HI,Whiteshrake
Use rewrite set-cookie is fantasy,it worked!But I got new situations.
Here is a new problem.
When I login,they will reponse an header,Set-Cookie like
Set-Cookie: SESSION_ID=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; domain=upstream.example; HttpOnly
Set-Cookie: SESSION_ID=79b9065a45630ccbb93b6f561fe6e58751423d5a; path=/; domain=upstream.example
Is Caddy can replace the domain to mine?
If we dont replce it , website will can not read session cookie.

I tried
header_downstream -Set-Cookie "domain=upstream.example"
header_downstream +Set-Cookie "domain="
Obviouly,It not gonna worked… That will make me loose all cookie and only have Cookie domain=
Can caddy handle this situations?
Updated:
@Whitestrake
Maybe I can use placeholder,Trying…
proxy /login http://upstream.example {
header_upstream Host upstream.example
header_upstream X-Real-IP {remote}
header_upstream X-Forwarded-For {remote}
header_upstream X-Forwarded-Proto {scheme}
websocket
header_upstream -Referer
header_upstream -Server
header_upstream +Cookie "SESSION_ID=guest"
header_downstream +Set-Cookie "SESSION_ID=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; domain=; HttpOnly"
header_downstream +Set-Cookie "SESSION_ID={~SESSION_ID}; path=/; domain="
header_downstream +Set-Cookie "LOGINCHK=Y; path=/; domain="
}
Got
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Date: Fri, 13 Apr 2018 03:31:30 GMT
Server: Caddy
Server: Caddy
Server: Apache
Set-Cookie: SESSION_ID=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; domain=upstream.example; HttpOnly
Set-Cookie: SESSION_ID=9c2040fec04e63db79f8fb0f09b19b1232e7d437; path=/; domain=upstream.example
Set-Cookie: LOGINCHK=Y; path=/; domain=upstream.example
Set-Cookie: SESSION_ID=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; domain=; HttpOnly
Set-Cookie: SESSION_ID=guest; path=/; domain=
Set-Cookie: LOGINCHK=Y; path=/; domain=
ahahaha,break down…
Three Server
,Double Set-Cookie.
Seems placeholder can not read value?THX
I read Documents, https://caddyserver.com/docs/placeholders
Response Placeholders seems not support Cookie…
SO how can I do that,is still have another way?