Using HTTP Host Header in Application Load Balancer Listener Rules

0

I am trying to reproduce and solve an issue of my customer. The intention was to reuse a single ALB for multiple URLs, which is hosted on a single HTTPD server listening two different ports. What I've done is to create two different Target Group, one for port 80 and one for port 81. Then I linked the two TG to a single ALB. Also, I have -- like my customer also did -- create a rule in ALB listener, so that any request with HTTP header HOST a.customerdomain.com be forwarded to TG1 on port 80, which any request withHTTP header HOST b.customerdomain.com be forwarded to TG2 on port 81. However, after my this setting, the request to a.customerdomain.com seems to work fine, while request b.customerdomain.com get 502 Bad Gateway .


Here is the other facts that might be related

  • Both DNS records has been set.
  • ALB security group open 443 to the internet
  • Both certs been issued in ACM and attached to the ALB
  • Security group of the instance allows traffic 80-81 from the whole VPC.
AWS
asked 3 months ago119 views
1 Answer
0

Hello.

Is the health check of the target group created for "b.customerdomain.com" successful?
Also, can you confirm that it is successfully listening on port 81 within EC2?
When accessing port 81 using the command below, will the request be returned normally?

curl localhost:81
profile picture
EXPERT
answered 3 months ago
  • By the way, the virtual host settings are as follows.

    cat /etc/httpd/conf.d/vhost.conf
    Listen 81
    <VirtualHost *:81>
      ServerName any
      DocumentRoot /var/www/html/81/
    </VirtualHost>
    
  • Both confirmed OK.

  • I tried the settings with my AWS account, and I was able to confirm that I could access both without any problems.

    curl http://test-1111111111.ap-northeast-1.elb.amazonaws.com -H 'Host:test.riku-kobayashi.net'
    80
    
    curl http://test-1111111111.ap-northeast-1.elb.amazonaws.com -H 'Host:riku-kobayashi.net'
    81
    

    By the way, what are your virtual host settings?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions