11

I am having a backend that is not able when running behind a reverse proxy since I cannot configure a custom base URL.

For the login process the backend makes heavy use of HTTP redirects but due to the fact that is behind a reverse proxy it sends redirection URL that are not reachable by the client.

So I was wondering if there is a way to rewrite the upstream HTTP HEADER Location

If the backend responses

HTTP/1.1 301
Location: http://backend-hostname/auth/login

Caddy should rewrite the Location header to

HTTP/1.1 301
Location: http://www.my-super-site.com/service/a/auth/login

Is something like this possible?

I've that we can remove headers by declaring

header / {
    - Location
}

but it possible to replace the header and rewrite the URL?

saw303
  • 8,051
  • 7
  • 50
  • 90

1 Answers1

1

I was also looking for answer for this question and unfortunately I've found this responses:

https://caddy.community/t/v2-reverse-proxy-but-upstream-server-redirects-to-nonexistent-path/8566

https://caddy.community/t/proxy-url-not-loading-site/5393/7

TLDR:

You need to use sub-domains rather than sub-paths for services that are not design for being after proxy (or at least configure base URL). :(

poplawskidaniel
  • 55
  • 1
  • 10