๐ŸŒฑ Spring Cloud - API Gateway Service (Routing) ๐ŸŒฑ

Kim Dae Hyunยท2021๋…„ 5์›” 26์ผ
1

Spring-Cloud

๋ชฉ๋ก ๋ณด๊ธฐ
2/4
post-thumbnail

Github ์†Œ์Šค์ฝ”๋“œ

Spring Cloud Gateway๋ฅผ ์ด์šฉํ•œ API Gateway Service ๊ตฌํ˜„ ๋ฐ Routing test

  • API Gateway ํ”„๋กœ์ ํŠธ ์„ค์ •
    • Spring-boot: 2.4.x
    • Dependency
      • Lombok, Spring Cloud Routing(Gateway), Eureka Client
  • ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•œ ์„œ๋น„์Šค ํ”„๋กœ์ ํŠธ ์„ค์ •
    • Spring-boot: 2.4.x
    • Dependency
      • Spring web, Eureka Client
  • Eureka Server๋Š” ์ด์ „ ํฌ์ŠคํŠธ์—์„œ ๊ตฌํ˜„ํ•œ ์„œ๋ฒ„๋ฅผ ์‚ฌ์šฉ

Routing

  • API gateway service yml์„ค์ •
  • Routing Test
    • first-service์™€ second-service์— ๊ฑฐ์˜ ๋™์ผํ•œ welcome๋ฉ”์„œ๋“œ๊ฐ€ ๊ตฌํ˜„๋˜์–ด ์žˆ๋‹ค.
    • ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•ด ๊ฐ ์„œ๋น„์Šค์˜ random port ์„ค์ •์„ ์ง€์šฐ๊ณ  first-service๋Š” 8081, second-service๋Š” 8082ํฌํŠธ๋กœ ์„ค์ •ํ•˜์˜€๋‹ค.
    • gateway service์™€ 2๊ฐœ ํ…Œ์ŠคํŠธ ์„œ๋น„์Šค๋ฅผ ๋ชจ๋‘ ๊ตฌ๋™์‹œํ‚ค๊ณ  ํ…Œ์ŠคํŠธ๋ฅผ ์ง„ํ–‰ํ•œ๋‹ค. (postman ์‚ฌ์šฉ)

gateway service๋ฅผ ํ†ตํ•ด first-service์™€ second-service๋กœ ๋ผ์šฐํŒ…์— ์„ฑ๊ณตํ•˜์˜€๋‹ค :)

profile
์ข€ ๋” ์ฒœ์ฒœํžˆ ๊นŒ๋จน๊ธฐ ์œ„ํ•ด ๊ธฐ๋กํ•ฉ๋‹ˆ๋‹ค. ๐Ÿง

0๊ฐœ์˜ ๋Œ“๊ธ€