Getting Error 522 with CloudFlare + AWS Application LoadBalancer

Getting Error 522 or 521, when accessing 80 or 443 port from ALB link its working (for 443 browser shows warning i.e because ALB and SSL domain is different)

AWS Config.

  1. Created Custom VPC with 1 public subnet and 1 private subnet
  2. Created AutoScaling Group
  3. Created Load Balancer (two listener for http and https forwording to traget group ) and target group (two targets pointing to Ec2 Instance on port 80 and 443 for heathcheck) -> health check is passing.
  4. Launched Ec2 instance in private subnet (no public ip), instance can only be access by application load balancer security group.

Ec2 and Apache2 Config.

  1. Enabled SSL in apache2

  2. Open port 443 in instance, Security Group of ALB and access port 80 (http) and 443 (https)

  3. For SSL followed article

Generated SSL Certificate from CloudFlare

  1. SSL/TLS -> Origin Server -> Generated RSA certificate

  2. Imported SSL certificate to AWS ACM

  3. Attached ACM SSL certificate to Loadbalancer HTTPS Listener

  4. Also create AWS ACM SSL certificate and validated with DNS for testing tried both ssl certificate - didn’t worked

Subdomain and ALB link

  1. Created DNS CNAME entry in CloudFlare

  2. Added subdomain which pointing to ALB link. (tried with proxy and DNS only)

  3. Your SSL/TLS encryption mode is Full

  4. Always Use HTTPS: ON

When hitting subdomain in normal window (browser) its getting 522 and in incognito mode for the first time it is working but after that not.

When making curl request to always working

Created extact duplicate instance in Public subnet and linked with another subdomain (created in cloudflare) just for testing -> working properly.

Also tried by adding separate target group for port 443 (HTTPS) -> in this traget group health check is getting failed whereas same working in other target group which for port 80 (http)

I’m not getting how to resolve this issue, please help!
Thank you.
Please Help!

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.