Skip to content

Commit 1742379

Browse files
TUN-7271: Return 503 status code when no ingress rules configured
1 parent 9c15f31 commit 1742379

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## 2023.3.1
22
### Breaking Change
3-
- 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.
3+
- 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.
44

55
## 2023.2.2
66
### Notices

component-tests/test_tunnel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ def test_tunnel_url(self, tmp_path, component_tests_config):
2424

2525
def test_tunnel_no_ingress(self, tmp_path, component_tests_config):
2626
'''
27-
Running a tunnel with no ingress rules provided from either config.yaml or CLI will still work but return 502
27+
Running a tunnel with no ingress rules provided from either config.yaml or CLI will still work but return 503
2828
for all incoming requests.
2929
'''
3030
config = component_tests_config(cfd_mode=CfdModes.NAMED, run_proxy_dns=False, provide_ingress=False)
3131
LOGGER.debug(config)
3232
with start_cloudflared(tmp_path, config, cfd_args=["run"], new_process=True):
3333
wait_tunnel_ready(require_min_connections=4)
3434
resp = send_request(config.get_url()+"/")
35-
assert resp.status_code == 502, "Expected cloudflared to return 502 for all requests with no ingress defined"
35+
assert resp.status_code == 503, "Expected cloudflared to return 503 for all requests with no ingress defined"
3636
resp = send_request(config.get_url()+"/test")
37-
assert resp.status_code == 502, "Expected cloudflared to return 502 for all requests with no ingress defined"
37+
assert resp.status_code == 503, "Expected cloudflared to return 503 for all requests with no ingress defined"
3838

3939

4040
@retry(stop_max_attempt_number=MAX_RETRIES, wait_fixed=BACKOFF_SECS * 1000)

ingress/ingress.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020

2121
var (
2222
ErrNoIngressRules = errors.New("The config file doesn't contain any ingress rules")
23-
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")
23+
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")
2424
errLastRuleNotCatchAll = errors.New("The last ingress rule must match all URLs (i.e. it should not have a hostname or path filter)")
2525
errBadWildcard = errors.New("Hostname patterns can have at most one wildcard character (\"*\") and it can only be used for subdomains, e.g. \"*.example.com\"")
2626
errHostnameContainsPort = errors.New("Hostname cannot contain a port")
@@ -129,7 +129,7 @@ func parseCLIIngress(c *cli.Context, allowURLFromArgs bool) (Ingress, error) {
129129
return ing, err
130130
}
131131

132-
// newDefaultOrigin always returns a 502 response code to help indicate that there are no ingress
132+
// newDefaultOrigin always returns a 503 response code to help indicate that there are no ingress
133133
// rules setup, but the tunnel is reachable.
134134
func newDefaultOrigin(c *cli.Context, log *zerolog.Logger) Ingress {
135135
noRulesService := newDefaultStatusCode(log)

ingress/origin_service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ func newStatusCode(status int) statusCode {
257257
return statusCode{code: status}
258258
}
259259

260-
// default status code (502) that is returned for requests to cloudflared that don't have any ingress rules setup
260+
// default status code (503) that is returned for requests to cloudflared that don't have any ingress rules setup
261261
func newDefaultStatusCode(log *zerolog.Logger) statusCode {
262-
return statusCode{code: 502, defaultResp: true, log: log}
262+
return statusCode{code: 503, defaultResp: true, log: log}
263263
}
264264

265265
func (o *statusCode) String() string {

0 commit comments

Comments
 (0)