@@ -401,8 +401,8 @@ gateway.addRoute({
401401 timeout: 5000 , // 5 second timeout
402402 path: ' /health' , // Health check endpoint
403403 expectedStatus: 200 , // Expected status code
404- unhealthyThreshold : 3 , // Failures before marking unhealthy
405- healthyThreshold : 2 , // Successes before marking healthy
404+ failureThreshold : 3 , // Failures before marking unhealthy
405+ successThreshold : 2 , // Successes before marking healthy
406406 },
407407 },
408408})
@@ -594,7 +594,7 @@ gateway.addRoute({
594594 enabled: true ,
595595 interval: 10000 ,
596596 path: ' /health' ,
597- unhealthyThreshold : 2 , // Fast failover
597+ failureThreshold : 2 , // Fast failover
598598 },
599599 },
600600})
@@ -650,12 +650,29 @@ healthCheck: {
650650 interval : 15000 ,
651651 timeout : 5000 ,
652652 path : ' /health' ,
653- unhealthyThreshold : 3 ,
654- healthyThreshold : 2 ,
653+ failureThreshold : 3 ,
654+ successThreshold : 2 ,
655655}
656656```
657657
658- ### 2. Use Circuit Breakers for External Services
658+ ### 2. Restrict Health Check Targets
659+
660+ For security, limit which schemes and hosts the load balancer may probe.
661+
662+ ``` typescript
663+ healthCheck : {
664+ enabled : true ,
665+ interval : 15000 ,
666+ timeout : 5000 ,
667+ path : ' /health' ,
668+ failureThreshold : 3 ,
669+ successThreshold : 2 ,
670+ allowedSchemes : [' http' , ' https' ],
671+ allowedHosts : [' 10.0.0.0/8' , ' api.internal.example.com' ],
672+ }
673+ ```
674+
675+ ### 3. Use Circuit Breakers for External Services
659676
660677``` typescript
661678circuitBreaker : {
@@ -666,7 +683,7 @@ circuitBreaker: {
666683}
667684```
668685
669- ### 3 . Configure Timeouts
686+ ### 4 . Configure Timeouts
670687
671688``` typescript
672689gateway .addRoute ({
@@ -681,7 +698,7 @@ gateway.addRoute({
681698})
682699```
683700
684- ### 4 . Monitor Target Health
701+ ### 5 . Monitor Target Health
685702
686703``` typescript
687704import { PinoLogger } from ' bungate'
@@ -698,7 +715,7 @@ gateway.on('target-healthy', (target) => {
698715})
699716```
700717
701- ### 5 . Use Appropriate Strategy
718+ ### 6 . Use Appropriate Strategy
702719
703720``` typescript
704721// ❌ DON'T use IP hash for APIs behind NAT
@@ -714,7 +731,7 @@ loadBalancer: {
714731}
715732```
716733
717- ### 6 . Plan for Capacity
734+ ### 7 . Plan for Capacity
718735
719736``` typescript
720737// Configure weights based on actual capacity
@@ -728,7 +745,7 @@ loadBalancer: {
728745}
729746```
730747
731- ### 7 . Test Failover Scenarios
748+ ### 8 . Test Failover Scenarios
732749
733750``` bash
734751# Simulate server failure
@@ -781,7 +798,7 @@ targets: [
781798healthCheck : {
782799 enabled : true ,
783800 timeout : 10000 , // Increase from 5000
784- unhealthyThreshold : 5 , // Require more failures
801+ failureThreshold : 5 , // Require more failures
785802}
786803
787804// 2. Check health endpoint performance
0 commit comments