TUN-7271: Return 503 status code when no ingress rules configured
This commit is contained in:
parent
9c15f31d00
commit
1742379ba4
|
@ -1,6 +1,6 @@
|
||||||
## 2023.3.1
|
## 2023.3.1
|
||||||
### Breaking Change
|
### 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
|
## 2023.2.2
|
||||||
### Notices
|
### Notices
|
||||||
|
|
|
@ -24,7 +24,7 @@ class TestTunnel:
|
||||||
|
|
||||||
def test_tunnel_no_ingress(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.
|
for all incoming requests.
|
||||||
'''
|
'''
|
||||||
config = component_tests_config(cfd_mode=CfdModes.NAMED, run_proxy_dns=False, provide_ingress=False)
|
config = component_tests_config(cfd_mode=CfdModes.NAMED, run_proxy_dns=False, provide_ingress=False)
|
||||||
|
@ -32,9 +32,9 @@ class TestTunnel:
|
||||||
with start_cloudflared(tmp_path, config, cfd_args=["run"], new_process=True):
|
with start_cloudflared(tmp_path, config, cfd_args=["run"], new_process=True):
|
||||||
wait_tunnel_ready(require_min_connections=4)
|
wait_tunnel_ready(require_min_connections=4)
|
||||||
resp = send_request(config.get_url()+"/")
|
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")
|
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)
|
@retry(stop_max_attempt_number=MAX_RETRIES, wait_fixed=BACKOFF_SECS * 1000)
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrNoIngressRules = errors.New("The config file doesn't contain any ingress rules")
|
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)")
|
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\"")
|
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")
|
errHostnameContainsPort = errors.New("Hostname cannot contain a port")
|
||||||
|
@ -129,7 +129,7 @@ func parseCLIIngress(c *cli.Context, allowURLFromArgs bool) (Ingress, error) {
|
||||||
return ing, err
|
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.
|
// rules setup, but the tunnel is reachable.
|
||||||
func newDefaultOrigin(c *cli.Context, log *zerolog.Logger) Ingress {
|
func newDefaultOrigin(c *cli.Context, log *zerolog.Logger) Ingress {
|
||||||
noRulesService := newDefaultStatusCode(log)
|
noRulesService := newDefaultStatusCode(log)
|
||||||
|
|
|
@ -257,9 +257,9 @@ func newStatusCode(status int) statusCode {
|
||||||
return statusCode{code: status}
|
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 {
|
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 {
|
func (o *statusCode) String() string {
|
||||||
|
|
Loading…
Reference in New Issue