问题
I have this Multidocker configuration, my HTTP traffic works fine no any problems, however, I get 408 every time I try to use https
{
"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": []
}
]
}
I have 3 node.js servers and a Nginx server all the images are uploaded to Amazon Elastic container repository, I added an SSL certificate with amazon certificate Manager and already open a port 443 in my classic load balancer in elastic beanstalk load balancer configuration, I checked the security group that is attached to the EB application and it redirects all HTTP and HTTPS traffic to the load balancer as well.
this is the nginx configuration
#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";
}
}
回答1:
Solved by Setting the instance port to 80 and the instance protocol to HTTP while keeping the load balancer port 443 and protocol HTTPS
来源:https://stackoverflow.com/questions/52494561/https-ssl-issues-on-aws-elastic-beanstalk-multicontainer-docker-configuration