1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# fbi-proxy default routing rules.
#
# Evaluated top-to-bottom; the first rule whose `match` pattern matches
# the incoming Host header (after stripping the port) wins.
#
# Placeholder syntax:
# {name} - one host segment, no dot ([^.]+)
# {name:int} - one numeric segment (\d+)
# {name:slug} - lowercase-alnum + dash ([a-z0-9-]+)
# {name:multi} - one or more dot-separated segments
#
# A placeholder name that appears in both the `match` pattern and the
# `target` / `headers` templates is substituted from its capture.
#
# These rules reproduce the hardcoded behavior of the original
# `parse_host` in rs/fbi-proxy.rs:
# * Rule 1 - "3000.fbi.com" -> localhost:3000
# * Rule 1.2 - "api--3001.fbi.com" -> api:3001 (Host: api)
# * Rule 3 - "admin.app.fbi.com" -> app:80 (Host: admin)
# * Rule 2 - "myserver.fbi.com" -> myserver:80 (Host: myserver)
#
# When no `--domain` is configured, the trailing `.{domain}` is absent
# from the incoming Host header. The `*-bare` rules below cover that
# case so behavior matches `parse_host` exactly:
# * "3000" -> localhost:3000 (Host: localhost)
# * "api--3001" -> api:3001 (Host: api)
# * "3000.localhost" -> localhost:80 (Host: 3000)
# * "localhost" -> localhost:80 (Host: localhost)
#
# Edit, reorder, or extend as needed.
version: 1
routes:
# 1. Port-as-host with domain: "3000.fbi.com" -> localhost:3000 (Host: localhost).
# Must come before host-double-dash-port-with-domain so a bare
# numeric subdomain isn't misinterpreted as a hostname.
- name: port-as-host
match: "{port:int}.{domain}"
target: "localhost:{port}"
# 2. Port-as-host bare (no --domain): "3000" -> localhost:3000.
- name: port-as-host-bare
match: "{port:int}"
target: "localhost:{port}"
# 3. Host--port with domain: "api--3001.fbi.com" -> api:3001, Host: api.
- name: host-double-dash-port
match: "{host}--{port:int}.{domain}"
target: "{host}:{port}"
headers:
Host: "{host}"
# 4. Host--port bare: "api--3001" -> api:3001, Host: api.
- name: host-double-dash-port-bare
match: "{host}--{port:int}"
target: "{host}:{port}"
headers:
Host: "{host}"
# 5. Subdomain hoisting with domain: "admin.app.fbi.com" -> app:80, Host: admin.
- name: subdomain-hoisting
match: "{prefix}.{host}.{domain}"
target: "{host}:80"
headers:
Host: "{prefix}"
# 6. Subdomain hoisting bare: "3000.localhost" -> localhost:80, Host: 3000.
- name: subdomain-hoisting-bare
match: "{prefix}.{host}"
target: "{host}:80"
headers:
Host: "{prefix}"
# 7. Direct forward with domain: "myserver.fbi.com" -> myserver:80, Host: myserver.
- name: direct-forward
match: "{host}.{domain}"
target: "{host}:80"
headers:
Host: "{host}"
# 8. Direct forward bare (catch-all): "localhost" -> localhost:80, Host: localhost.
- name: direct-forward-bare
match: "{host}"
target: "{host}:80"
headers:
Host: "{host}"