URL Configuration
When running Gate in proxy
mode, you can configure target URLs for redirection.
In ext_auth
and aws_lambda_auth
mode, the target
value is ignored.
Defining URL mapping
You can map request URLs to specific target URLs. Paths are matched in order of insertion.
- Environment variables
- HCL
- JSON
- TOML
- YAML
GATE_URLS_0_PATTERN=svc-example.com/*
GATE_URLS_0_TARGET=http://example:8080
GATE_URLS_1_PATTERN=svc-another-example.com/
GATE_URLS_1_TARGET=https://another-example:8080
gate = {
urls = [
{
pattern = "svc-example.com/*"
target = "http://example:8080"
},
{
pattern = "svc-another-example.com/"
target = "https://another-example:8080"
}
]
// ...
}
{
"gate": {
"urls": [
{
"pattern": "svc-example.com/*",
"target": "http://example:8080",
},
{
"pattern": "svc-another-example.com/",
"target": "https://another-example:8080"
}
],
// ...
URL are matched in the order they are defined in the configuration file.
[[gate.urls]]
pattern = "svc-example.com/*"
target = "http://example:8080"
[[gate.urls]]
pattern = "svc-another-example.com/"
target = "https://another-example:8080"
URL are matched in the order they are defined in the configuration file.
gate:
urls:
- pattern: svc-example.com/*
target: http://example:8080
- pattern: svc-another-example.com/
target: https://another-example:8080
URL are matched in the order they are defined in the configuration file.
When configuring Gate through environment variables, the URL number defines the order in which URLs are matched.
In the example above, the GATE_URLS_0
URL will be matched first, and the GATE_URLS_1
URL will be matched second.
When using configuration files (any format), URLs are matched in the order in which they are specified in the configuration file.
If the request URL does not match with any of the defined paths, the default target URL is used.
Default target URL
You can define the default target URL for Gate, which will be called if no mapped URL is matched.
- Environment variables
- HCL
- JSON
- TOML
- YAML
GATE_DEFAULT_TARGET=http://default-svc:8080
gate = {
default = {
target = "http://default-svc:8080"
}
// ...
}
{
"gate": {
"default": {
"target": "http://default-svc:8080"
},
// ...
[gate.default]
target = "http://default-svc:8080"
gate:
default:
target: http://default-svc:8080
Pattern format
You can specify static paths as pattern
, and use wildcards with *
.
A few examples:
Pattern | Request | Matches | Comment |
---|---|---|---|
example.localhost/foo | example.localhost/foo | ✅ | |
example.localhost/* | example.localhost/foo | ✅ | |
example.localhost/* | example.localhost/foo/bar | ✅ | |
*/foo | example.localhost/foo | ✅ | |
*.example.localhost/foo | foo.example.localhost/foo | ✅ | |
other.localhost/foo | example.localhost/foo | ❌ | Domain is different |
other.localhost/foo | example.localhost/foo | ❌ | Domain is different |
example.localhost:8080/foo | example.localhost/foo | ❌ | Port is different |
example.localhost:*/foo | example.localhost:8899/foo | ✅ | |
example.localhost/foo | example.localhost/ | ❌ | |
example.localhost/foo/*/bar | example.localhost/foo/foo_id/bar | ✅ | |
example.localhost/foo/* | example.localhost/foo/foo_id/bar/bar_id | ✅ | |
example.localhost/foo/ | example.localhost/foo/?foo=bar | ✅ | Query parameters are not required in the pattern |