mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 20:50:00 +00:00
TUN-7259: Add warning for missing ingress rules
Providing no ingress rules in the configuration file or via the CLI will now provide a warning and return 502 for all incoming HTTP requests.
This commit is contained in:
@@ -247,13 +247,26 @@ func (o helloWorld) MarshalJSON() ([]byte, error) {
|
||||
// Typical use-case is "user wants the catch-all rule to just respond 404".
|
||||
type statusCode struct {
|
||||
code int
|
||||
|
||||
// Set only when the user has not defined any ingress rules
|
||||
defaultResp bool
|
||||
log *zerolog.Logger
|
||||
}
|
||||
|
||||
func newStatusCode(status int) statusCode {
|
||||
return statusCode{code: status}
|
||||
}
|
||||
|
||||
// default status code (502) that is returned for requests to cloudflared that don't have any ingress rules setup
|
||||
func newDefaultStatusCode(log *zerolog.Logger) statusCode {
|
||||
return statusCode{code: 502, defaultResp: true, log: log}
|
||||
}
|
||||
|
||||
func (o *statusCode) String() string {
|
||||
// returning a different service name can help with identifying users via config that don't setup ingress rules
|
||||
if o.defaultResp {
|
||||
return "default_http_status:502"
|
||||
}
|
||||
return fmt.Sprintf("http_status:%d", o.code)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user