{ "vhost": { "id": "site", "frontend": {"hosts": ["site.test", "*.site.test"], "listener_ids": ["http"]}, "backends": [ {"id": "app", "url": "http://127.0.0.1:9000", "allow_private": true}, {"id": "beta", "url": "http://127.0.0.1:9001", "allow_private": true, "pool_eligible": false}, {"id": "office", "url": "http://127.0.0.1:9002", "allow_private": true, "pool_eligible": false}, {"id": "mp3_1", "url": "http://127.0.0.1:9011", "allow_private": true, "pool_eligible": false}, {"id": "mp3_2", "url": "http://127.0.0.1:9012", "allow_private": true, "pool_eligible": false} ], "load_balancing": {"health_check": {"mode": "off"}}, "routes": [ {"id": "health", "match_type": "exact", "path_prefix": "/health", "response": {"status": 200, "body": "ok"}}, {"id": "health-post", "match_type": "exact", "path_prefix": "/health", "conditions": [{"source": "method", "values": ["POST", "put"]}], "response": {"status": 405, "body": "no"}}, {"id": "api-beta", "path_prefix": "/api/", "backend_ids": ["beta"], "conditions": [{"source": "header", "name": "X-Beta", "values": ["1", "yes"], "ignore_case": true}]}, {"id": "api", "path_prefix": "/api/"}, {"id": "api-v2-tenant", "path_prefix": "/api/v2/", "backend_ids": ["beta"], "conditions": [{"source": "query", "name": "tenant", "operator": "prefix", "values": ["test-"]}]}, {"id": "office", "match_type": "any", "backend_ids": ["office"], "conditions": [{"source": "ip", "operator": "cidr", "values": ["10.0.0.0/8", "192.0.2.7"]}, {"source": "cookie", "name": "staff", "operator": "exists"}]}, {"id": "mp3-eu", "match_type": "regex_insensitive", "path_prefix": "\\.mp3$", "backend_ids": ["mp3_1"], "conditions": [{"source": "country", "values": ["pl", "DE"]}]}, {"id": "mp3", "match_type": "regex_insensitive", "path_prefix": "\\.mp3$", "backend_ids": ["mp3_1", "mp3_2"], "load_balancing": {"algorithm": "hash"}}, {"id": "not-bot", "match_type": "any", "backend_ids": ["beta"], "conditions": [{"source": "host", "operator": "suffix", "values": [".beta.site.test"]}, {"source": "header", "name": "User-Agent", "operator": "regex", "values": ["(?i)bot"], "negate": true}]} ] }, "cases": [ {"name": "plain page goes to the vhost pool", "path": "/index.html", "expect": "main"}, {"name": "exact unconditional", "path": "/health", "expect": "health"}, {"name": "exact with method condition wins", "method": "POST", "path": "/health", "expect": "health-post"}, {"name": "method values are case-insensitive", "method": "PUT", "path": "/health", "expect": "health-post"}, {"name": "api without header", "path": "/api/users", "expect": "api"}, {"name": "api with header", "path": "/api/users", "headers": {"x-beta": "YES"}, "expect": "api-beta"}, {"name": "api with other header value", "path": "/api/users", "headers": {"x-beta": "0"}, "expect": "api"}, {"name": "longer prefix with query condition", "path": "/api/v2/items", "query": "tenant=test-acme", "expect": "api-v2-tenant"}, {"name": "longer prefix condition fails, falls back to shorter prefix", "path": "/api/v2/items", "query": "tenant=acme", "expect": "api"}, {"name": "any-path rule: office network with staff cookie", "path": "/index.html", "client_ip": "10.20.30.40", "headers": {"cookie": "a=1; staff=1"}, "expect": "office"}, {"name": "any-path rule beats plain prefix like a regex", "path": "/api/users", "client_ip": "192.0.2.7", "headers": {"cookie": "staff="}, "expect": "office"}, {"name": "any-path rule needs all conditions", "path": "/index.html", "client_ip": "10.20.30.40", "expect": "main"}, {"name": "exact still wins over any-path rule", "path": "/health", "client_ip": "10.1.1.1", "headers": {"cookie": "staff=1"}, "expect": "health"}, {"name": "regex with country", "path": "/m/song.MP3", "country": "PL", "expect": "mp3-eu"}, {"name": "regex country miss", "path": "/m/song.mp3", "country": "US", "expect": "mp3"}, {"name": "regex without country", "path": "/m/song.mp3", "expect": "mp3"}, {"name": "host suffix with negated user agent", "host": "x.beta.site.test", "path": "/", "headers": {"user-agent": "Mozilla/5.0"}, "expect": "not-bot"}, {"name": "negated condition blocks bots", "host": "x.beta.site.test", "path": "/", "headers": {"user-agent": "Googlebot/2.1"}, "expect": "main"}, {"name": "host condition miss", "host": "site.test", "path": "/", "expect": "main"} ] }