@@ -229,38 +229,6 @@ Then, you can add the ALBs along with listeners and target groups:
229229 - !Ref CoreUrl
230230 ListenerArn: !Ref InternalALBListener
231231 Priority: 100
232- CoreListenerRule:
233- Type: AWS::ElasticLoadBalancingV2::ListenerRule
234- Properties:
235- Actions:
236- - Type: forward
237- TargetGroupArn: !Ref CoreTargetGroup
238- Conditions:
239- - Field: host-header
240- Values:
241- - !Select
242- - 2
243- - !Split
244- - /
245- - !Ref CoreUrl
246- ListenerArn: !Ref InternalALBListener
247- Priority: 100
248- CoreListenerRule404:
249- Type: AWS::ElasticLoadBalancingV2::ListenerRule
250- Properties:
251- Actions:
252- - Type: fixed-response
253- FixedResponseConfig:
254- StatusCode: "404"
255- ContentType: text/plain
256- MessageBody: "Not Found"
257- Conditions:
258- - Field: host-header
259- HostHeaderConfig:
260- Values:
261- - "*"
262- ListenerArn: !Ref InternalALBListener
263- Priority: 200
264232 ProxyListenerRule:
265233 Type: AWS::ElasticLoadBalancingV2::ListenerRule
266234 Properties:
@@ -277,22 +245,48 @@ Then, you can add the ALBs along with listeners and target groups:
277245 - !Ref ProxyUrl
278246 ListenerArn: !Ref ALBListener
279247 Priority: 100
280- ProxyListenerRule404 :
281- Type: AWS::ElasticLoadBalancingV2::ListenerRule
248+ CoreTargetGroup :
249+ Type: AWS::ElasticLoadBalancingV2::TargetGroup
282250 Properties:
283- Actions:
284- - Type: fixed-response
285- FixedResponseConfig:
286- StatusCode: "404"
287- ContentType: text/plain
288- MessageBody: "Not Found"
289- Conditions:
290- - Field: host-header
291- HostHeaderConfig:
292- Values:
293- - "*"
294- ListenerArn: !Ref ALBListener
295- Priority: 200
251+ Name: defguard-core-tg
252+ Port: !Ref CoreHttpPort
253+ Protocol: HTTP
254+ VpcId: !Ref VPC
255+ TargetType: instance
256+ HealthCheckEnabled: true
257+ HealthCheckPath: /api/v1/health
258+ HealthCheckProtocol: HTTP
259+ HealthCheckIntervalSeconds: 30
260+ HealthCheckTimeoutSeconds: 5
261+ HealthyThresholdCount: 2
262+ UnhealthyThresholdCount: 3
263+ Targets:
264+ - Id: !Ref CoreInstance
265+ Port: !Ref CoreHttpPort
266+ Tags:
267+ - Key: Name
268+ Value: defguard-core-tg
269+ ProxyTargetGroup:
270+ Type: AWS::ElasticLoadBalancingV2::TargetGroup
271+ Properties:
272+ Name: defguard-proxy-tg
273+ Port: !Ref ProxyHttpPort
274+ Protocol: HTTP
275+ VpcId: !Ref VPC
276+ TargetType: instance
277+ HealthCheckEnabled: true
278+ HealthCheckPath: /health
279+ HealthCheckProtocol: HTTP
280+ HealthCheckIntervalSeconds: 30
281+ HealthCheckTimeoutSeconds: 5
282+ HealthyThresholdCount: 2
283+ UnhealthyThresholdCount: 3
284+ Targets:
285+ - Id: !Ref ProxyInstance
286+ Port: !Ref ProxyHttpPort
287+ Tags:
288+ - Key: Name
289+ Value: defguard-proxy-tg
296290` ` `
297291
298292Then, modify the Core and Proxy security groups to allow traffic from the ALBs :
@@ -386,13 +380,11 @@ To easily inspect the ALB DNS names, you can add the following outputs to your t
386380
387381` ` ` yaml
388382 LoadBalancerDNS:
389- Condition: CreateLoadBalancer
390383 Description: The DNS name of the Public Application Load Balancer
391384 Value: !GetAtt ApplicationLoadBalancer.DNSName
392385 Export:
393386 Name: !Sub ${AWS::StackName}-alb-dns
394387 InternalLoadBalancerDNS:
395- Condition: CreateInternalLoadBalancer
396388 Description: The DNS name of the Internal Application Load Balancer
397389 Value: !GetAtt InternalApplicationLoadBalancer.DNSName
398390 Export:
0 commit comments