Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/app/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func TestProxyEntrypointsValidateNamesAndPorts(t *testing.T) {
{"built-in port", "proxy: {entrypoints: {otlp: {port: 443}}}\n", "websecure"},
{"duplicate port", "proxy: {entrypoints: {otlp-grpc: {port: 4317}, otlp-http: {port: 4317}}}\n", "both publish port 4317"},
{"invalid port", "proxy: {entrypoints: {otlp: {port: 70000}}}\n", "proxy.entrypoints.otlp.port"},
{"traefik internal name", "proxy: {entrypoints: {traefik: {port: 9000}}}\n", "reserved: Traefik uses it for its internal entrypoint"},
{"traefik ping port", "proxy: {entrypoints: {admin: {port: 8080}}}\n", "ping health check"},
{"neighbour of ping port", "proxy: {entrypoints: {admin: {port: 8081}}}\n", ""},
} {
t.Run(tc.name, func(t *testing.T) {
_, err := loadFixtureBytes([]byte(min+tc.yaml), "ob.yml")
Expand Down
26 changes: 26 additions & 0 deletions internal/app/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ func validateSpec(p *Spec) error {
return validateTopLevel(p)
}

// traefikInternalPort is where Traefik opens its internal "traefik"
// entrypoint when ping, the API or metrics are enabled without an explicit
// entryPoint, as Onebox's static configuration does for ping.
const traefikInternalPort = 8080

// traefikInternalEntrypoint is the name of that internal entrypoint.
const traefikInternalEntrypoint = "traefik"

func validateTopLevel(p *Spec) error {
if err := checkEnum("proxy.kind", p.Proxy.Kind, eProxyKind); err != nil {
return err
Expand Down Expand Up @@ -107,10 +115,28 @@ func validateTopLevel(p *Spec) error {
return errf("project_invalid", path, "",
"proxy entrypoint %q is built in and cannot be redeclared", name)
}
// Traefik gives this name to its internal entrypoint. Declaring it
// does not fail: it silently becomes that entrypoint, so the ping
// health check moves off :8080 onto the declared, published port and
// is served to the internet beside the routes.
if name == traefikInternalEntrypoint {
return errf("project_invalid", path, "",
"proxy entrypoint name %q is reserved: Traefik uses it for its internal entrypoint, which serves the managed proxy's ping health check, "+
"and a declared one would publish that check on its port; choose another name", name)
}
port := p.Proxy.Entrypoints[name].Port
if err := checkPort(path+".port", port); err != nil {
return err
}
// Onebox's static configuration enables ping without naming an
// entrypoint, so Traefik serves it from its internal "traefik"
// entrypoint on :8080. A declared listener there cannot bind, and the
// proxy fails to start on the host rather than here.
if port == traefikInternalPort {
return errf("project_invalid", path+".port", "",
"proxy entrypoint %q cannot publish port %d: the managed Traefik already listens there for its ping health check (its internal \"traefik\" entrypoint); choose another port",
name, port)
}
if previous, exists := seenEntrypointPorts[port]; exists {
return errf("project_invalid", path+".port", "",
"proxy entrypoints %q and %q both publish port %d", previous, name, port)
Expand Down
7 changes: 7 additions & 0 deletions site/src/content/docs/docs/reference/project-file.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,13 @@ Each declared port is published on the host by the managed proxy. Use this for
remote clients; workloads on the same host can communicate over Onebox's
internal networks without opening another host port. The route's `port` is the
workload's listening port, while `entrypoint` selects the proxy listener.
Ports `80` and `443` belong to `web` and `websecure`, and port `8080` is
reserved too: the managed Traefik serves its ping health check from its
internal `traefik` entrypoint there, so a declared listener on `8080` could
never bind.
The name `traefik` is reserved for the same reason: declaring it would
redefine that internal entrypoint and publish the health check on the declared
port.

When Onebox writes the static proxy configuration, including when
`proxy.config` contains only dynamic extensions, it also writes these named
Expand Down
Loading