diff --git a/CHANGES.md b/CHANGES.md index e34f8615733..d11b3578ef2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,6 @@ ## 2023.3.1 ### Breaking Change -- Running a tunnel without ingress rules defined in configuration file nor from the CLI flags will no longer provide a default ingress rule to localhost:8080 and instead will return HTTP response code 502 for all incoming HTTP requests. +- Running a tunnel without ingress rules defined in configuration file nor from the CLI flags will no longer provide a default ingress rule to localhost:8080 and instead will return HTTP response code 503 for all incoming HTTP requests. ## 2023.2.2 ### Notices diff --git a/component-tests/test_tunnel.py b/component-tests/test_tunnel.py index 9a193aec83e..d6978825b58 100644 --- a/component-tests/test_tunnel.py +++ b/component-tests/test_tunnel.py @@ -24,7 +24,7 @@ def test_tunnel_url(self, tmp_path, component_tests_config): def test_tunnel_no_ingress(self, tmp_path, component_tests_config): ''' - Running a tunnel with no ingress rules provided from either config.yaml or CLI will still work but return 502 + Running a tunnel with no ingress rules provided from either config.yaml or CLI will still work but return 503 for all incoming requests. ''' config = component_tests_config(cfd_mode=CfdModes.NAMED, run_proxy_dns=False, provide_ingress=False) @@ -32,9 +32,9 @@ def test_tunnel_no_ingress(self, tmp_path, component_tests_config): with start_cloudflared(tmp_path, config, cfd_args=["run"], new_process=True): wait_tunnel_ready(require_min_connections=4) resp = send_request(config.get_url()+"/") - assert resp.status_code == 502, "Expected cloudflared to return 502 for all requests with no ingress defined" + assert resp.status_code == 503, "Expected cloudflared to return 503 for all requests with no ingress defined" resp = send_request(config.get_url()+"/test") - assert resp.status_code == 502, "Expected cloudflared to return 502 for all requests with no ingress defined" + assert resp.status_code == 503, "Expected cloudflared to return 503 for all requests with no ingress defined" @retry(stop_max_attempt_number=MAX_RETRIES, wait_fixed=BACKOFF_SECS * 1000) diff --git a/ingress/ingress.go b/ingress/ingress.go index 2b20fc48680..926d1bf13ee 100644 --- a/ingress/ingress.go +++ b/ingress/ingress.go @@ -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) diff --git a/ingress/origin_service.go b/ingress/origin_service.go index 99953c4f670..361470f216f 100644 --- a/ingress/origin_service.go +++ b/ingress/origin_service.go @@ -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 {