TUN-7271: Return 503 status code when no ingress rules configured

This commit is contained in:
Sudarsan Reddy
2023-03-13 09:24:20 +00:00
parent 9c15f31d00
commit 1742379ba4
4 changed files with 8 additions and 8 deletions

View File

@@ -20,7 +20,7 @@ import (
var (
ErrNoIngressRules = errors.New("The config file doesn't contain any ingress rules")
ErrNoIngressRulesCLI = errors.New("No ingress rules were defined in provided config (if any) nor from the cli, cloudflared will return 502 for all incoming HTTP requests")
ErrNoIngressRulesCLI = errors.New("No ingress rules were defined in provided config (if any) nor from the cli, cloudflared will return 503 for all incoming HTTP requests")
errLastRuleNotCatchAll = errors.New("The last ingress rule must match all URLs (i.e. it should not have a hostname or path filter)")
errBadWildcard = errors.New("Hostname patterns can have at most one wildcard character (\"*\") and it can only be used for subdomains, e.g. \"*.example.com\"")
errHostnameContainsPort = errors.New("Hostname cannot contain a port")
@@ -129,7 +129,7 @@ func parseCLIIngress(c *cli.Context, allowURLFromArgs bool) (Ingress, error) {
return ing, err
}
// newDefaultOrigin always returns a 502 response code to help indicate that there are no ingress
// newDefaultOrigin always returns a 503 response code to help indicate that there are no ingress
// rules setup, but the tunnel is reachable.
func newDefaultOrigin(c *cli.Context, log *zerolog.Logger) Ingress {
noRulesService := newDefaultStatusCode(log)

View File

@@ -257,9 +257,9 @@ 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
// default status code (503) 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}
return statusCode{code: 503, defaultResp: true, log: log}
}
func (o *statusCode) String() string {