New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy preset `transparent` should use X-Forwarded-Port and server port placeholder #2412

Open
xNephe opened this Issue Dec 28, 2018 · 0 comments

Comments

2 participants
@xNephe
Copy link

xNephe commented Dec 28, 2018

Hello,

When configuring Caddy as a reverse proxy for an nginx instance (serving a php app in a container), I had two issues:

  • X-Forwarded-Port is not included in the preset transparent. I had to add it by hand.
  • There is no placeholder for the server port. I had to hardcode it to 443.

After a discussion on the forum, when came to the conclusion it may be worth a discussion here.

What I propose is:

  1. To define a placeholder representing the server port used by a request. Let's call it {server-port} for now.

  2. To add header_upstream X-Forwarded-Port {server-port} in the transparent preset. I don't see any reason why a transparent proxy shouldn't transmit the inital port.

Thanks!


1. What version of Caddy are you using (caddy -version)?

Caddy 0.11.1 (from https://hub.docker.com/r/abiosoft/caddy/, tag 0.11.1)

2. What are you trying to do?

Set up a reverse proxy that correctly transmit the server port.

3. What is your entire Caddyfile?

domain.com {
  proxy / app:8888 {
    transparent
    header_upstream X-Forwarded-Port 443  # Without this line, the proxy does not transmit the port and port 888 is used by app
  }
}

app:8888 redirect toward another container where an nginx instance serve a php app.

4. How did you run Caddy (give the full command and describe the execution environment)?

Docker image from https://hub.docker.com/r/abiosoft/caddy/, tag 0.11.1

5. Please paste any relevant HTTP request(s) here.

N/A

6. Expected behavior?

  • There is a placeholder for the server port, so I can write header_upstream X-Forwarded-Port {server-port}

  • X-Forwarded-Port is included in the preset transparent so I can write

domain.com {
  proxy / app:8888 {
    transparent
  }
}

and the port is correctly transmitted.

7. What did you see instead (give full error messages and/or log)?

  • There is no placeholder for the server port

  • Using only the preset transparent leads to an invalid port being used by the app to load css and js files.

8. How can someone who is starting from scratch reproduce the bug as minimally as possible?

Set up a caddy instance with the Caddyfile above.
Inspect the X-Forwarded-Port in the transmitted header.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment