Issue
I have two containers on AWS EC2 instance and I run them with docker-compose. These two different containers consisted of the backend and frontend images of my project. When I run it with the DNS address + :3000 port on AWS, I can see the front-end page, but when I try to login in my project (sign-up endpoint gets the same error), I get an ERR_CONNECTION_REFUSED error.
So I thought there might be a problem with the ports.
- When I send a request from postman on AWS's DNS address + :8080, the backend responds to me without any problems.
- The cURL requests (localhost:8080) made in the instance's terminal to the backend work without any problems.
- However, the frontend cannot send requests to the backend listening on localhost:8080 in the same instance.
What am I missing?
Extras:
DOCKER-COMPOSE FILE
version: '3'
services:
book-portal-back-end:
image: "ugurcanerdogan/book-portal-be:v1"
container_name: ugurcanerdogan-bookPortal-be
ports:
- "8080:8080"
environment:
- SPRING.PROFILES.ACTIVE=default
book-portal-front-end:
image: "ugurcanerdogan/book-portal-fe:v1"
container_name: ugurcanerdogan-bookPortal-fe
ports:
- "3000:3000"
links:
- book-portal-back-end
Inbound rules of instance:
Solution
The real problem here was my "login" endpoint. There was no really a /login endpoint (I was catching login requests with filters, I didn't have any login endpoints under a @Controller) so every request was being denied. I changed my JWT and login-register implementation now it works well!
Answered By - uqi8
Answer Checked By - Katrina (JavaFixing Volunteer)