解決的辦法是配置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"
- 創建一個名爲.ebextensions在WEB-INF文件夾 也許在新的版本中.ebextensions文件夾有在根文件夾中,有人可以證實這一點嗎?
- 此文件夾中與上述
- 將應用程序部署
- 內容創建一個名爲websocket.config文件重建環境
對於沒有設置SSL刪除此:
- {LoadBalancerPort: 443, InstanceProtocol: "TCP", InstancePort: 8080, Protocol: "SSL", SSLCertificateId: "arn:aws:iam::9999999999999:server-certificate/sslcert"}
或將Apache替換爲Nginx並將Niginx配置爲支持WebSocket
是你EC2安全組允許端口80? –
是的,我可以通過端口80訪問每個servlet。只是協議升級不起作用。 – patrick
它接縫爲Tomcat前EC2實例上的Apache Proxy – patrick