我正在尝试在Elastic Beanstalk上运行一个简单的websocket echo应用程序。但是,如果我运行它,我在Tomcat的套接字升级上收到错误400,但这只是在端口80上发生,如果我通过端口8080认为loadbalancer我可以在套接字升级时访问websocket而没有错误400(在端口8080上) )。端口8080和端口80都在TCP而不是HTTP上。
我的问题是谁在进行从80到8080的转换,因为loadbalancer上的默认配置只是将流量从80传递到80.转换必须在EC2实例上。 iptables的?在这个翻译中出了点问题。
从亚马逊那里得到一些关于这种交通是如何路由的信息会很好。
答案 0 :(得分:16)
解决方案是将Loadbalacer配置为直接连接到Tomcat:
Resources:
AWSEBSecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
GroupDescription: "Security group to allow HTTP, SSH and 8080 for all"
SecurityGroupIngress:
- {CidrIp: "0.0.0.0/0", IpProtocol: "tcp", FromPort: "80", ToPort: "80"}
- {CidrIp: "0.0.0.0/0", IpProtocol: "tcp", FromPort: "8080", ToPort: "8080"}
- {CidrIp: "0.0.0.0/0", IpProtocol: "tcp", FromPort: "22", ToPort: "22"}
AWSEBLoadBalancer:
Type: "AWS::ElasticLoadBalancing::LoadBalancer"
Properties:
Listeners:
- {LoadBalancerPort: 443, InstanceProtocol: "TCP", InstancePort: 8080, Protocol: "SSL", SSLCertificateId: "arn:aws:iam::9999999999999:server-certificate/sslcert"}
- {LoadBalancerPort: 80, InstanceProtocol: "TCP", InstancePort: 8080, Protocol: "TCP"}
AppCookieStickinessPolicy:
- {PolicyName: "lb-session", CookieName: "lb-session"}
HealthCheck:
HealthyThreshold: "3"
Interval: "30"
Target: "HTTP:8080/ping.html"
Timeout: "5"
UnhealthyThreshold: "5"
对于没有SSL的设置,请删除:
- {LoadBalancerPort: 443, InstanceProtocol: "TCP", InstancePort: 8080, Protocol: "SSL", SSLCertificateId: "arn:aws:iam::9999999999999:server-certificate/sslcert"}