묻고 답해요
129만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
해결됨Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
api-gateway 서버를 실행시키고 first-service와 second-service 를 실행시키면 api-gateway가 실행이 잘 안됩니다.
안녕하세요 Spring Cloud Gateway 프로젝트 생성 강의를 진행했는데요 제가 first-service와 second-service 그리고 api-gateway를 모두 Spring Boot 2.6.10 버전 java 11 버전 sdk도 11 로 생성했습니다. 우선 api-gateway의 application.yml 파일은 다음과 같습니다. server: port: 8000eureka: client: register-with-eureka: false fetch-registry: false service-url: defaultZone: http://localhost:8761/eurekaspring: application: name: apigateway-service cloud: gateway: routes: - id: first-service uri: http://localhost:8081/ # 여기로 요청할거다. predicates: # 조건절이다. - Path=/first-service/** # 사용자가 이걸호출하면 위에 uri로 간다. 즉 http://localhost:8081/first-service/** 으로 간다. - id: second-service uri: http://localhost:8082/ # 여기로 요청할거다. predicates: # 조건절이다. - Path=/second-service/** # 사용자가 이걸호출하면 위에 uri로 간다. first-service의 application.yml 파일은 다음과 같고 server: port: 8081spring: application: name: my-first-serviceeureka: client: fetch-registry: false register-with-eureka: false FirstServiceController는 다음과 같습니다. @RestController@RequestMapping("/first-service")public class FirstServiceController { @GetMapping("/welcome") public String welcome() { return "Welcome to the First service"; }} 또한 second-service의 application.yml은 다음과 같고 server: port: 8082spring: application: name: my-second-serviceeureka: client: fetch-registry: false register-with-eureka: false SecondServiceController는 다음과 같습니다. @RestController@RequestMapping("/second-service")public class SecondServiceController { @GetMapping("/welcome") public String welcome() { return "Welcome to the Second service"; }} 브라우저에 http://127.0.0.1:8081/first-service/welcome 을 입력하면 Welcome to the First service가 잘뜨고 http://127.0.0.1:8082/second-service/welcome 을 입력하면 Welcome to the Second service 가 잘 뜹니다. 그런데 http://127.0.0.1:8000/first-sevice/welcome http://127.0.0.1:8000/second-sevice/welcome 을 입력하면 역시나 동일하게 Welcome to the ~ 가 나와야하는데 Whitelabel Error Page 404 에러가 발생합니다... 원인이 무엇일까요? 참고로 api-gateway 서버를 먼저키고 first, second 켜보기도하고 first, second 서버 먼저 키고 api-gateway를 켜보기도했는데 상관없이 똑같은 에러가 발생합니다.
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
Api gateway 필터
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 Api gateway 필터 설정에서 remove request header=Cookie를 하는 이유가 무엇인가요?
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
GlobalFilter에서 CustomFilter로 이동하는 이유
GlobalFilter에서 갑자기 CustomFilter로 이동하는 이유가 궁금합니다.
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
gateway 필터에서 ip주소 확인하기
선생님! gateway 필터에서 request한 client의 ip주소를 확인할 수 있는 방법은 없나요?
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
Gateway와 set-Cookie 에 대한 질문입니다.
안녕하세요 강사님 해당 강의를 통해서 엄청난 꺠달음과 영감을 얻게되어 감사하다는 말씀을 먼저 올리고싶습니다. 제가 해당 강의를 통해서 성장을 하여 감히 마이크로서비스를 이용해서 프로젝트를 진행하고 있습니다. 하지만 프로젝트를 진행하다 보니 몇일 동안 해결할 수 없는 문제와 마주하게 되어 이렇게 문의 드립니다. 우선 Spring Cloud Gateway 가 존재하고 User-Service 가 그 뒤에 위치해 있습니다. User-Service 에서는 사용자가 로그인을 한다면 access_token 과 refresh_token 을 쿠키에 담아서 반환합니다. 그리고 로그아웃을 한다면 access_token 과 refresh_token 의 쿠키 값에 null 을 넣고 expires 를 과거로 만들어 만료되도록 합니다. Front 에서는 로그인을 수행하면 access_token 과 refresh_token 을 잘 받아서 브라우저에 저장하는 것을 확인하였습니다. 로그아웃을 수행한다면 응답으로 set-cookie 를 잘 받아오는 것도 확인을 하였습니다. - access_token=; expires= 1960 00:00:00 ... httpOnly; - refresh_token=; expires= 1960 00:00:00... httpOnly; 하지만 실제 브라우저에서는 쿠키가 지워지지 않더라구요.. axios의 credential 과 gateway 에서의 cors filter 도 설정을 잘 하였습니다. 실제 프로젝트 소스는 아래에 있습니다. - User-Service :: https://github.com/dhslrl321/PCUSS-User-Service - Gateway Service :: https://github.com/dhslrl321/PCUSS-Gateway-Server - Front 비동기 통신 코드 :: https://github.com/dhslrl321/PCUSS-Official-Site/blob/master/client/services/authService.js - Front axios 모듈 :: https://github.com/dhslrl321/PCUSS-Official-Site/blob/master/client/utils/api.js