Skip to content
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

httpcaddyfile: Add shortcut for proxy hostport placeholder #4263

Merged
merged 2 commits into from
Aug 12, 2021

Conversation

francislavoie
Copy link
Member

@francislavoie francislavoie commented Aug 2, 2021

I've noticed that it's a pretty common pattern to write a proxy like this, when needing to proxy over HTTPS:

reverse_proxy https://example.com {
	header_up Host {http.reverse_proxy.upstream.hostport}
}

I find it pretty hard to remember the exact placeholder to use for this, and I continually need to refer to the docs when I need it. I think a simple fix for this is to add another Caddyfile shortcut for this one to shorten it:

reverse_proxy https://example.com {
	header_up Host {upstream_hostport}
}

I've noticed that it's a pretty common pattern to write a proxy like this, when needing to proxy over HTTPS:

```
reverse_proxy https://example.com {
	header_up Host {http.reverse_proxy.upstream.hostport}
}
```

I find it pretty hard to remember the exact placeholder to use for this, and I continually need to refer to the docs when I need it. I think a simple fix for this is to add another Caddyfile placeholder for this one to shorten it:

```
reverse_proxy https://example.com {
	header_up Host {proxy_hostport}
}
```
@francislavoie francislavoie added this to the v2.4.4 milestone Aug 2, 2021
@francislavoie francislavoie assigned mholt and unassigned mholt Aug 2, 2021
@francislavoie francislavoie requested a review from mholt August 2, 2021 20:42
@mholt
Copy link
Member

mholt commented Aug 3, 2021

I support this. How do you feel about {upstream_hostport} instead? (I'm mostly fine with {proxy_hostport}, except that the value isn't actually the host+port of the proxy, it's of the upstream.)

@francislavoie
Copy link
Member Author

That works too. I'll change it.

@francislavoie
Copy link
Member Author

francislavoie commented Aug 12, 2021

I think this is ready to go too @mholt

Will just need to be reflected in /website after

Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks!

@mholt mholt merged commit ab32440 into master Aug 12, 2021
@francislavoie francislavoie deleted the proxy-caddyfile-shortcut branch August 12, 2021 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants