I am unable to connect to my site via https though using http its working. I used docker compose and build it on the ec2 machine. So in simple way i am not uploading any image to ecs/ecr, but pushing code to github and pulling to ec2 instance. Then i run it as i do locally. Every thing work fine except that i am unable to access it via https. On aws , i have take following steps to configure https
- Create certificate via AWS certificate manager and verify it via DNS Create load balance
- Create new SG group having inbound rule for both http and https and source everywhere (0.0.0.0/0)
- Create a target group with http and connect it to my instance
- Add https listener and Select certificate from ACM for https listener
- check target group health and there is no issue
- Through my domain , ip, DNS name of load balance i can access website but not with https
Now i am not sure, where did i made the mistake, is the issue on docker site or on load balancer site. Though in terminal of EC2, i can see "ELB-HealthChecker/2.0" which mean the issue is not with ELB. It is with docker. This is the docker-compose file i used
version: '3'
services:
django_app: #can be any name, this name should match in default conf
volumes:
- static_vol:/app/sub_app/static
- media_vol:/app/sub_app/media
env_file:
- .env
build:
context: .
ports:
- "8000:8000"
nginx:
build: ./nginx
volumes:
- static_vol:/app/sub_app/static
- media_vol:/app/sub_app/media
ports:
- "80:80"
depends_on:
- django_app
volumes:
static_vol:
media_vol:
Now I have no clue where the things went wrong. Looking for help
EDIT Console after ELB,
I can see ELB connected
As i am using nginx, may be there is some issue. Here is default.conf file
upstream django {
server django_app:8000;
}
server {
listen 80;
location / {
proxy_pass http://django;
}
location /static/ {
alias /app/sub_app/static/;
}
location /media/ {
alias /app/sub_app/media/;
}
}
CodePudding user response:
You need to configure the HTTPS listener on the load balancer to forward to port 80 on the target server. You shouldn't be opening port 443
in the docker-compose
file, because you don't have an SSL certificate installed in the Nginx container. The SSL certificate you created is served by the load balancer, not Nginx.