| ... | @@ -24,9 +24,13 @@ def nomad(path, token): | ... | @@ -24,9 +24,13 @@ def nomad(path, token): |
| 24 | return json.load(response) | 24 | return json.load(response) |
| 25 | | 25 | |
| 26 | | 26 | |
| | 27 | def passive_health(upstreams, indent): |
| | 28 | return [f"{indent}fail_duration 30s"] if len(upstreams.split()) > 1 else [] |
| | 29 | |
| | 30 | |
| 27 | def proxy(upstreams, indent, uncompressed=False, host=None): | 31 | def proxy(upstreams, indent, uncompressed=False, host=None): |
| 28 | lines = [f"{indent}reverse_proxy {upstreams} {{", f"{indent} lb_try_duration 5s", | 32 | lines = [f"{indent}reverse_proxy {upstreams} {{", f"{indent} lb_try_duration 5s", |
| 29 | f"{indent} fail_duration 30s"] | 33 | *passive_health(upstreams, indent + " ")] |
| 30 | if uncompressed: | 34 | if uncompressed: |
| 31 | lines.append(f"{indent} header_up Accept-Encoding identity") | 35 | lines.append(f"{indent} header_up Accept-Encoding identity") |
| 32 | if host: | 36 | if host: |
| ... | @@ -261,7 +265,7 @@ def render(token): | ... | @@ -261,7 +265,7 @@ def render(token): |
| 261 | if route["userHeader"]: | 265 | if route["userHeader"]: |
| 262 | lines.append(f" request_header -{route['userHeader']}") | 266 | lines.append(f" request_header -{route['userHeader']}") |
| 263 | lines += [ | 267 | lines += [ |
| 264 | f" reverse_proxy {auth} {{", " lb_try_duration 5s", " fail_duration 30s", " method GET", | 268 | f" reverse_proxy {auth} {{", " lb_try_duration 5s", *passive_health(auth, " "), " method GET", |
| 265 | " rewrite /snow.oauth2/auth", " header_up X-Forwarded-Method {method}", | 269 | " rewrite /snow.oauth2/auth", " header_up X-Forwarded-Method {method}", |
| 266 | " header_up X-Forwarded-Uri {uri}", " @unauthorized status 401", | 270 | " header_up X-Forwarded-Uri {uri}", " @unauthorized status 401", |
| 267 | " handle_response @unauthorized {", | 271 | " handle_response @unauthorized {", |
| ... | @@ -286,7 +290,7 @@ def render(token): | ... | @@ -286,7 +290,7 @@ def render(token): |
| 286 | lines += [" handle /snow.oauth2/* {", *proxy(auth," "), " }"] | 290 | lines += [" handle /snow.oauth2/* {", *proxy(auth," "), " }"] |
| 287 | lines += [" handle {"] | 291 | lines += [" handle {"] |
| 288 | lines += [f" request_header -{name}" for name in scrub] | 292 | lines += [f" request_header -{name}" for name in scrub] |
| 289 | lines += [f" reverse_proxy {auth} {{", " lb_try_duration 5s", " fail_duration 30s", " method GET", " rewrite " + ("/auth/file/check" if native else "/snow.oauth2/auth"), | 293 | lines += [f" reverse_proxy {auth} {{", " lb_try_duration 5s", *passive_health(auth, " "), " method GET", " rewrite " + ("/auth/file/check" if native else "/snow.oauth2/auth"), |
| 290 | *([f" header_up Studio-Proxy-Token {dashboard_proof}"] if native else []), | 294 | *([f" header_up Studio-Proxy-Token {dashboard_proof}"] if native else []), |
| 291 | " header_up X-Forwarded-Method {method}", " header_up X-Forwarded-Uri {uri}", | 295 | " header_up X-Forwarded-Method {method}", " header_up X-Forwarded-Uri {uri}", |
| 292 | " @authenticated status 2xx", " handle_response @authenticated {"] | 296 | " @authenticated status 2xx", " handle_response @authenticated {"] |