我有这个Multidocker配置,我的HTTP通信正常,没有任何问题,但是,每次尝试使用https时都会得到408
{
"AWSEBDockerrunVersion": 2,
"containerDefinitions": [
{
"name": "users-managment",
"image": "....",
"essential": true,
"memory": 256,
"portMappings": [
{
"hostPort": 3000,
"containerPort": 3000
}
],
"environment": [
{
"name": "PORT",
"value": "3000"
}
],
"mountPoints": []
},
{
"name": "presence",
"image": "...ecr",
"essential": true,
"memory": 256,
"portMappings": [
{
"hostPort": 3001,
"containerPort": 3001
}
],
"environment": [
{
"name": "USERS_SERVICE",
"value": "http://users-managment:3000"
},
{
"name": "PORT",
"value": "3001"
}
],
"links": ["users-managment"],
"mountPoints": []
},
{
"name": "signaling",
"image": "...dkr.ecr...",
"environment": [
{
"name": "PORT",
"value": "3002"
}
],
"essential": true,
"memory": 256,
"portMappings": [
{
"hostPort": 3002,
"containerPort": 3002
}
],
"links": ["users-managment"],
"mountPoints": []
},
{
"name": "api-gateway",
"image": "...dkr.ecr...",
"essential": true,
"memory": 128,
"portMappings": [
{
"hostPort": 80,
"containerPort": 80
},
{
"hostPort": 443,
"containerPort": 443
}
],
"links": ["signaling", "presence", "users-managment"],
"mountPoints": []
}
]
}
我有3个node.js服务器和Nginx服务器,所有图像都上传到了Amazon Elastic容器存储库,我添加了带有Amazon Certificate Manager的SSL证书,并已经在我的经典bean负载均衡器配置的经典负载均衡器中打开了端口443,检查了附加到EB应用程序的安全组,它还将所有HTTP和HTTPS通信也重定向到负载平衡器。
这是nginx的配置
#The actual HTTPS server
server {
listen 80;
listen 443;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
location /users {
proxy_pass http://users-managment:3000;
}
location /docs/users {
proxy_pass http://users-managment:3000;
}
location /ice/servers {
proxy_pass http://signaling:3002;
}
#For Server-1
location /signaling/ {
#Configure proxy to pass data to upstream node1
proxy_pass http://signaling:3002/socket.io/;
#HTTP version 1.1 is needed for sockets
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
#For Server-2
location /presence/ {
#Configure proxy to pass data to upstream node2
proxy_pass http://presence:3001/socket.io/;
#HTTP version 1.1 is needed for sockets
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
最佳答案
通过将实例端口设置为80并将实例协议设置为HTTP并同时保持负载均衡器端口443和协议HTTPS来解决
关于amazon-web-services - AWS Elastic Beanstalk多容器Docker配置上的HTTPS/SSL问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52494561/