Rewrite HTTPS proxy redirects?

Hi,
when I have this Caddy config:

sub.domain.com {
    proxy / https://remote.domain.com
}

When I click link on https://sub.domain.com , the webpage redirects to another https://differentremote.domain.com .

How can I get Caddy to rewrite webpages, so I can continue using https://sub.domain.com for browsing, and it does not redirect to different URL in my browser?

Well, Caddy isn’t configured here to do any redirects. Are you sure you have cleared your browser cache?

Maybe the backend is sending the browser a redirect?

Yes backend redirects to another subdomain to provide auth.

Is there any way to handle that?

You could try:

    proxy_header Host {host}
    proxy_header X-Real-IP {remote}
    proxy_header X-Forwarded-For {remote}
    proxy_header X-Forwarded-Proto {scheme}

in your proxy directive (I assume you’re still running 0.8.3). In 0.9 these will be replaced with the transparent preset and proxy_header becomes header_upstream.