{
	"admin": {
		"listen": "localhost:2019",
		"origins": [
			"localhost",
			"127.0.0.1"
		]
	},
	"logging": {
		"logs": {
			"default": {
				"writer": {
					"output": "stdout"
				},
				"encoder": {
					"format": "json"
				},
				"level": "INFO",
				"exclude": [
					"http.log.access.log0"
				]
			},
			"log0": {
				"writer": {
					"output": "stdout"
				},
				"encoder": {
					"fields": {
						"request\u003eclient_ip": {
							"filter": "ip_mask",
							"ipv4_cidr": 16,
							"ipv6_cidr": 32
						},
						"request\u003eheaders\u003eAuthorization": {
							"filter": "delete"
						},
						"request\u003eheaders\u003eCookie": {
							"filter": "delete"
						},
						"request\u003eremote_ip": {
							"filter": "ip_mask",
							"ipv4_cidr": 16,
							"ipv6_cidr": 32
						},
						"request\u003euri": {
							"filter": "regexp",
							"regexp": "^([^?]*)\\\\?.*$",
							"value": "$1"
						}
					},
					"format": "filter",
					"wrap": {
						"format": "json"
					}
				},
				"level": "INFO",
				"include": [
					"http.log.access.log0"
				]
			}
		}
	},
	"apps": {
		"http": {
			"servers": {
				"srv0": {
					"listen": [
						":443"
					],
					"listener_wrappers": [
						{
							"routes": [
								{
									"handle": [
										{
											"handler": "proxy",
											"upstreams": [
												{
													"dial": [
														"tcp/host.docker.internal:5349"
													]
												}
											]
										}
									],
									"match": [
										{
											"tls": {
												"sni": [
													"api-abc.test.example.test.example"
												]
											}
										}
									]
								}
							],
							"wrapper": "layer4"
						},
						{
							"wrapper": "tls"
						}
					],
					"routes": [
						{
							"match": [
								{
									"host": [
										"api-abc.test.example.test.example"
									]
								}
							],
							"handle": [
								{
									"handler": "subroute",
									"routes": [
										{
											"handle": [
												{
													"handler": "static_response",
													"status_code": 421
												}
											]
										}
									]
								}
							],
							"terminal": true
						},
						{
							"match": [
								{
									"host": [
										"www.test.example"
									]
								}
							],
							"handle": [
								{
									"handler": "subroute",
									"routes": [
										{
											"handle": [
												{
													"handler": "static_response",
													"headers": {
														"Location": [
															"https://test.example{http.request.uri}"
														]
													},
													"status_code": 301
												}
											]
										}
									]
								}
							],
							"terminal": true
						},
						{
							"match": [
								{
									"host": [
										"test.example"
									]
								}
							],
							"handle": [
								{
									"handler": "subroute",
									"routes": [
										{
											"handle": [
												{
													"handler": "headers",
													"response": {
														"deferred": true,
														"delete": [
															"Server",
															"Via",
															"Alt-Svc"
														],
														"set": {
															"Referrer-Policy": [
																"no-referrer"
															],
															"Strict-Transport-Security": [
																"max-age=31536000; includeSubDomains"
															],
															"X-Content-Type-Options": [
																"nosniff"
															],
															"X-Frame-Options": [
																"DENY"
															]
														}
													}
												},
												{
													"encodings": {
														"gzip": {},
														"zstd": {}
													},
													"handler": "encode",
													"prefer": [
														"gzip",
														"zstd"
													]
												}
											]
										},
										{
											"group": "group10",
											"handle": [
												{
													"handler": "subroute",
													"routes": [
														{
															"handle": [
																{
																	"handler": "reverse_proxy",
																	"upstreams": [
																		{
																			"dial": "host.docker.internal:8920"
																		}
																	]
																}
															]
														}
													]
												}
											],
											"match": [
												{
													"path": [
														"/sfu/ws/*"
													]
												}
											]
										},
										{
											"group": "group10",
											"handle": [
												{
													"handler": "subroute",
													"routes": [
														{
															"handle": [
																{
																	"handler": "reverse_proxy",
																	"upstreams": [
																		{
																			"dial": "host.docker.internal:8912"
																		}
																	]
																}
															]
														}
													]
												}
											],
											"match": [
												{
													"path": [
														"/relay/*"
													]
												}
											]
										},
										{
											"group": "group10",
											"handle": [
												{
													"handler": "subroute",
													"routes": [
														{
															"handle": [
																{
																	"handler": "headers",
																	"response": {
																		"set": {
																			"Cache-Control": [
																				"public, max-age=31536000, immutable"
																			]
																		}
																	}
																}
															],
															"match": [
																{
																	"path_regexp": {
																		"name": "immutable",
																		"pattern": "/_app/immutable/.*"
																	}
																}
															]
														},
														{
															"handle": [
																{
																	"handler": "reverse_proxy",
																	"headers": {
																		"request": {
																			"set": {
																				"Host": [
																					"oxpulse.chat"
																				],
																				"X-Channel-Tag": [
																					"{http.reverse_proxy.upstream.hostport}"
																				],
																				"X-Forwarded-Host": [
																					"test.example"
																				],
																				"X-Forwarded-Proto": [
																					"https"
																				],
																				"X-Geo-Country": [
																					"{http.vars.maxmind_country_code}"
																				]
																			}
																		}
																	},
																	"health_checks": {
																		"active": {
																			"expect_status": 2,
																			"fails": 3,
																			"interval": 10000000000,
																			"passes": 2,
																			"timeout": 3000000000,
																			"uri": "/api/health"
																		}
																	},
																	"load_balancing": {
																		"retries": 2,
																		"selection_policy": {
																			"policy": "first"
																		},
																		"try_duration": 5000000000,
																		"try_interval": 250000000
																	},
																	"upstreams": [
																		{
																			"dial": "10.9.0.2:8907"
																		},
																		{
																			"dial": "xray-client:3080"
																		},
																		{
																			"dial": "host.docker.internal:18443"
																		},
																		{
																			"dial": "127.0.0.1:1080"
																		}
																	]
																}
															],
															"match": [
																{
																	"path": [
																		"/events/*"
																	]
																}
															]
														},
														{
															"handle": [
																{
																	"handler": "reverse_proxy",
																	"headers": {
																		"request": {
																			"set": {
																				"Host": [
																					"oxpulse.chat"
																				],
																				"X-Channel-Tag": [
																					"{http.reverse_proxy.upstream.hostport}"
																				],
																				"X-Forwarded-Host": [
																					"test.example"
																				],
																				"X-Forwarded-Proto": [
																					"https"
																				],
																				"X-Geo-Country": [
																					"{http.vars.maxmind_country_code}"
																				]
																			}
																		}
																	},
																	"health_checks": {
																		"active": {
																			"expect_status": 2,
																			"fails": 3,
																			"interval": 10000000000,
																			"passes": 2,
																			"timeout": 3000000000,
																			"uri": "/api/health"
																		}
																	},
																	"load_balancing": {
																		"retries": 2,
																		"selection_policy": {
																			"policy": "first"
																		},
																		"try_duration": 5000000000,
																		"try_interval": 250000000
																	},
																	"upstreams": [
																		{
																			"dial": "10.9.0.2:8907"
																		},
																		{
																			"dial": "xray-client:3080"
																		},
																		{
																			"dial": "host.docker.internal:18443"
																		},
																		{
																			"dial": "127.0.0.1:1080"
																		}
																	]
																}
															],
															"match": [
																{
																	"path": [
																		"/api/*"
																	]
																}
															]
														},
														{
															"handle": [
																{
																	"handler": "reverse_proxy",
																	"headers": {
																		"request": {
																			"set": {
																				"Host": [
																					"oxpulse.chat"
																				],
																				"X-Channel-Tag": [
																					"{http.reverse_proxy.upstream.hostport}"
																				],
																				"X-Forwarded-Host": [
																					"test.example"
																				],
																				"X-Forwarded-Proto": [
																					"https"
																				],
																				"X-Geo-Country": [
																					"{http.vars.maxmind_country_code}"
																				]
																			}
																		}
																	},
																	"health_checks": {
																		"active": {
																			"expect_status": 2,
																			"fails": 3,
																			"interval": 10000000000,
																			"passes": 2,
																			"timeout": 3000000000,
																			"uri": "/api/health"
																		}
																	},
																	"load_balancing": {
																		"retries": 2,
																		"selection_policy": {
																			"policy": "first"
																		},
																		"try_duration": 5000000000,
																		"try_interval": 250000000
																	},
																	"upstreams": [
																		{
																			"dial": "10.9.0.2:8907"
																		},
																		{
																			"dial": "xray-client:3080"
																		},
																		{
																			"dial": "host.docker.internal:18443"
																		},
																		{
																			"dial": "127.0.0.1:1080"
																		}
																	]
																}
															],
															"match": [
																{
																	"path": [
																		"/ws/*"
																	]
																}
															]
														},
														{
															"handle": [
																{
																	"handler": "reverse_proxy",
																	"headers": {
																		"request": {
																			"set": {
																				"Host": [
																					"oxpulse.chat"
																				],
																				"X-Channel-Tag": [
																					"{http.reverse_proxy.upstream.hostport}"
																				],
																				"X-Forwarded-Host": [
																					"test.example"
																				],
																				"X-Forwarded-Proto": [
																					"https"
																				],
																				"X-Geo-Country": [
																					"{http.vars.maxmind_country_code}"
																				]
																			}
																		}
																	},
																	"health_checks": {
																		"active": {
																			"expect_status": 2,
																			"fails": 3,
																			"interval": 10000000000,
																			"passes": 2,
																			"timeout": 3000000000,
																			"uri": "/api/health"
																		}
																	},
																	"load_balancing": {
																		"retries": 2,
																		"selection_policy": {
																			"policy": "first"
																		},
																		"try_duration": 5000000000,
																		"try_interval": 250000000
																	},
																	"upstreams": [
																		{
																			"dial": "10.9.0.2:8907"
																		},
																		{
																			"dial": "xray-client:3080"
																		},
																		{
																			"dial": "host.docker.internal:18443"
																		},
																		{
																			"dial": "127.0.0.1:1080"
																		}
																	]
																}
															]
														}
													]
												}
											]
										}
									]
								}
							],
							"terminal": true
						}
					],
					"errors": {
						"routes": [
							{
								"match": [
									{
										"host": [
											"test.example"
										]
									}
								],
								"handle": [
									{
										"handler": "subroute",
										"routes": [
											{
												"handle": [
													{
														"handler": "subroute",
														"routes": [
															{
																"handle": [
																	{
																		"handler": "headers",
																		"response": {
																			"set": {
																				"Content-Type": [
																					"text/html; charset=utf-8"
																				]
																			}
																		}
																	},
																	{
																		"body": "\u003c!doctype html\u003e\n\u003chtml lang=\"ru\"\u003e\n\u003chead\u003e\n\u003cmeta charset=\"utf-8\"\u003e\n\u003cmeta name=\"viewport\" content=\"width=device-width,initial-scale=1\"\u003e\n\u003ctitle\u003eСоединение прервано / Connection interrupted\u003c/title\u003e\n\u003cstyle\u003e\n  *{box-sizing:border-box;margin:0;padding:0}\n  body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;\n    background:#0f172a;color:#e2e8f0;display:flex;align-items:center;\n    justify-content:center;min-height:100vh;padding:1rem}\n  .card{background:#1e293b;border:1px solid #334155;border-radius:12px;\n    padding:2rem;max-width:420px;width:100%;text-align:center}\n  h1{font-size:1.25rem;font-weight:600;margin-bottom:.5rem;color:#f8fafc}\n  p{font-size:.9rem;color:#94a3b8;line-height:1.6;margin-bottom:1.25rem}\n  .code{font-size:.75rem;color:#64748b;margin-bottom:1.5rem}\n  button{background:#3b82f6;color:#fff;border:none;border-radius:8px;\n    padding:.6rem 1.5rem;font-size:.9rem;cursor:pointer;transition:background .2s}\n  button:hover{background:#2563eb}\n  #countdown{font-size:.8rem;color:#64748b;margin-bottom:1rem}\n\u003c/style\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\u003cdiv class=\"card\"\u003e\n  \u003ch1\u003eСоединение прервано\u003c/h1\u003e\n  \u003cp\u003eСвязь с сервером временно прервана.\u003cbr\u003e\n     Страница повторит попытку автоматически.\u003c/p\u003e\n  \u003cp lang=\"en\" style=\"font-size:.8rem;color:#64748b\"\u003eConnection to the server was interrupted.\n     Retrying automatically.\u003c/p\u003e\n  \u003cdiv id=\"countdown\"\u003e\u003c/div\u003e\n  \u003cdiv class=\"code\"\u003e{http.error.status_code}\u003c/div\u003e\n  \u003cbutton onclick=\"sessionStorage.removeItem('_re');location.reload()\"\u003eПовторить / Retry\u003c/button\u003e\n\u003c/div\u003e\n\u003cscript\u003e\n  // Exponential backoff retry: 4s → 8s → 16s → 32s → cap 60s.\n  // Attempt counter persisted in sessionStorage so it survives the reload\n  // but resets when the tab is closed (no stale state across sessions).\n  var attempts = parseInt(sessionStorage.getItem('_re') || '0', 10);\n  var delays = [4, 8, 16, 32, 60];\n  var delay = delays[Math.min(attempts, delays.length - 1)];\n  sessionStorage.setItem('_re', attempts + 1);\n  var remaining = delay;\n  var cd = document.getElementById('countdown');\n  function tick() {\n    if (remaining \u003c= 0) { location.reload(); return; }\n    cd.textContent = 'Повтор через ' + remaining + ' с / Retrying in ' + remaining + 's';\n    remaining--;\n    setTimeout(tick, 1000);\n  }\n  tick();\n\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e",
																		"handler": "static_response",
																		"status_code": "{http.error.status_code}"
																	}
																]
															}
														]
													}
												],
												"match": [
													{
														"expression": "{http.error.status_code} in [502, 503, 504]"
													}
												]
											}
										]
									}
								],
								"terminal": true
							}
						]
					},
					"logs": {
						"logger_names": {
							"test.example": [
								"log0"
							]
						},
						"skip_hosts": [
							"api-abc.test.example.test.example",
							"www.test.example"
						]
					},
					"protocols": [
						"h1",
						"h2"
					]
				},
				"srv1": {
					"listen": [
						":80"
					],
					"listener_wrappers": [
						{
							"routes": [
								{
									"handle": [
										{
											"handler": "proxy",
											"upstreams": [
												{
													"dial": [
														"tcp/host.docker.internal:5349"
													]
												}
											]
										}
									],
									"match": [
										{
											"tls": {
												"sni": [
													"api-abc.test.example.test.example"
												]
											}
										}
									]
								}
							],
							"wrapper": "layer4"
						},
						{
							"wrapper": "tls"
						}
					],
					"routes": [
						{
							"match": [
								{
									"host": [
										"www.test.example"
									]
								}
							],
							"handle": [
								{
									"handler": "subroute",
									"routes": [
										{
											"handle": [
												{
													"handler": "static_response",
													"headers": {
														"Location": [
															"https://test.example{http.request.uri}"
														]
													},
													"status_code": 301
												}
											]
										}
									]
								}
							],
							"terminal": true
						}
					],
					"protocols": [
						"h1",
						"h2"
					]
				},
				"srv2": {
					"listen": [
						":9080"
					],
					"listener_wrappers": [
						{
							"routes": [
								{
									"handle": [
										{
											"handler": "proxy",
											"upstreams": [
												{
													"dial": [
														"tcp/host.docker.internal:5349"
													]
												}
											]
										}
									],
									"match": [
										{
											"tls": {
												"sni": [
													"api-abc.test.example.test.example"
												]
											}
										}
									]
								}
							],
							"wrapper": "layer4"
						},
						{
							"wrapper": "tls"
						}
					],
					"routes": [
						{
							"match": [
								{
									"host": [
										"127.0.0.1"
									]
								}
							],
							"handle": [
								{
									"handler": "subroute",
									"routes": [
										{
											"group": "group13",
											"handle": [
												{
													"handler": "subroute",
													"routes": [
														{
															"handle": [
																{
																	"body": "6cfcba248a101a0fb3a0b7f3e199bad03b854252384edc314e93655d01b67ac6",
																	"handler": "static_response",
																	"status_code": 200
																}
															]
														}
													]
												}
											],
											"match": [
												{
													"path": [
														"/canary/config-hash"
													]
												}
											]
										},
										{
											"group": "group13",
											"handle": [
												{
													"handler": "subroute",
													"routes": [
														{
															"handle": [
																{
																	"body": "{\"routes\":[\"tunnel\",\"sfu\",\"relay\",\"branding\"]}",
																	"handler": "static_response",
																	"status_code": 200
																}
															]
														}
													]
												}
											],
											"match": [
												{
													"path": [
														"/canary/route-table"
													]
												}
											]
										},
										{
											"group": "group13",
											"handle": [
												{
													"handler": "subroute",
													"routes": [
														{
															"handle": [
																{
																	"handler": "reverse_proxy",
																	"transport": {
																		"dial_timeout": 2000000000,
																		"protocol": "http",
																		"response_header_timeout": 2000000000
																	},
																	"upstreams": [
																		{
																			"dial": "xray-client:3080"
																		}
																	]
																}
															]
														}
													]
												}
											],
											"match": [
												{
													"path": [
														"/canary/upstream"
													]
												}
											]
										},
										{
											"group": "group13",
											"handle": [
												{
													"handler": "subroute",
													"routes": [
														{
															"group": "group4",
															"handle": [
																{
																	"handler": "rewrite",
																	"uri": "/api/health/live"
																}
															]
														},
														{
															"handle": [
																{
																	"handler": "reverse_proxy",
																	"transport": {
																		"dial_timeout": 2000000000,
																		"protocol": "http",
																		"response_header_timeout": 2000000000
																	},
																	"upstreams": [
																		{
																			"dial": "xray-client:3080"
																		}
																	]
																}
															]
														}
													]
												}
											],
											"match": [
												{
													"path": [
														"/canary/tunnel"
													]
												}
											]
										}
									]
								}
							],
							"terminal": true
						}
					],
					"automatic_https": {
						"skip": [
							"127.0.0.1"
						]
					},
					"protocols": [
						"h1",
						"h2"
					]
				}
			},
			"metrics": {}
		},
		"tls": {
			"automation": {
				"policies": [
					{
						"subjects": [
							"api-abc.test.example.test.example"
						],
						"issuers": [
							{
								"challenges": {
									"tls-alpn": {
										"disabled": true
									}
								},
								"email": "admin@test.example",
								"module": "acme"
							}
						]
					},
					{
						"subjects": [
							"www.test.example",
							"test.example"
						],
						"issuers": [
							{
								"email": "admin@test.example",
								"module": "acme"
							},
							{
								"ca": "https://acme.zerossl.com/v2/DV90",
								"email": "admin@test.example",
								"module": "acme"
							}
						]
					}
				]
			}
		}
	}
}
