The solution is to configure the Loadbalacer to connect directly to the 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"
- Create a folder called .ebextensions in the WEB-INF folder
Maybe in newer Version the .ebextensions has to be in the root folder, can somebody confirm this?
- Create a file called websocket.config in this folder with the content from above
- Deploy the application
- Rebuild the environment
For a setup without SSL remove this:
- {LoadBalancerPort: 443, InstanceProtocol: "TCP", InstancePort: 8080, Protocol: "SSL", SSLCertificateId: "arn:aws:iam::9999999999999:server-certificate/sslcert"}
Or replace Apache by Nginx and configure Niginx to support WebSocket
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…