I am new in Web development, and now I got some obstacles bothering me a couple of days. I was using docker-compose to run my both front and backend on EC2 instance.
So, in order to make my web-app public accessible, I need to change my frontend port from 3000 --> 80 like the Docker-Compose.yaml below.
However, although now the frontend was showing publicly, but now unable to GET the data from my backend. Got an error message: " net::ERR_CONNECTION_REFUSED".
I believe it's because the PORT issue, so I came out a couple of solutions, but don't know whether it's doable?:
Maybe I can adjust security group of the instance to make port 3000 accessible, so no need to revise the docker-compose file?
By redirecting the port 80 to 3000 written in the frontend? So, my backend is still connecting port 3000?
Or I am on the wrong path?
Docker-Compose.yaml:
Version: "3.2"
services:
project:
restart: always
container_name: coin
command : bash -c "python manage.py runserver 0.0.0.0:8000"
build:
context: ./coin_api/
dockerfile: dockerfile
ports:
- "8000:8000"
frontend:
restart: always
command : npm start
container_name: front
build:
context: ./frontend/
dockerfile: dockerfile
ports:
- "3000:3000" # In order to make it accessible to public, I changed to 80:3000
# but then, now my frontend is unable to connect to backend and get data.
stdin_open: true
networks:
db-net:
driver: bridge
Security Group of the EC2 Instance: