Backend Language

Proxy Server ์—ฐ๊ฒฐ์€ ๋ณธ domain ํ˜น์€ ip์— ํ•˜์ง€ ์•Š๊ณ  Sub Domain์— ์—ฐ๊ฒฐํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ๋‹ค์Œ ์œ„์น˜์— Proxy Server Code๋ฅผ ์ž‘์„ฑํ•ด๋‘๋ฉด ๋œ๋‹ค. prod subDomain์— ์—ฐ๊ฒฐํ•ด ๋‘˜ ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ž‘์„ฑํ•œ๋‹ค. server { root /var/www/html/prod; index index.php index.html index.htm index.nginx-debian.html; server_name prod.๋„๋ฉ”์ธ์ด๋ฆ„.shop; location / { proxy_pass http://localhost:9000; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_..
๊ฐ„๋‹จํ•˜๊ฒŒ ์„œ๋ฒ„ ๋ฐฐํฌ ๋ฐ ๋ฌด์ค‘๋‹จ ๋ฐฐํฌํ•œ ๊ฒƒ์„ ์ •๋ฆฌํ•ด๋ณด๊ณ ์ž ํ•œ๋‹ค. sudo su # update sudo apt update # nginx proxy server ์‚ฌ์šฉํ•  ์˜ˆ์ •์ด๊ธฐ ๋•Œ๋ฌธ์— nginx ๋‹ค์šด sudo apt install nginx # domain ์—ฐ๊ฒฐ ๋ฐ proxy server ์—ฐ๊ฒฐ # default ํŒŒ์ผ ๋ณ€๊ฒฝ vim /etc/nginx/sites-avaliable/default # default file ๋‚ด๋ถ€ server_name _; # ์ด๋ถ€๋ถ„์— ์›ํ•˜๋Š” ๋„๋ฉ”์ธ ์—ฐ๊ฒฐ location ~~{ # 404 ๋ญ์‹œ๊ธฐ ์ฃผ์„ ์ฒ˜๋ฆฌ proxy_pass http://localhost:8080; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwa..
com.mysql.cj.jdbc.exceptions.communicationsexception: communications link failure the last packet sent successfully to the server was 0 milliseconds ago. the driv er has not received any packets from the server. ์•ฑ ๋Ÿฐ์นญ์„ ์œ„ํ•ด ์„œ๋ฒ„๋ฅผ ๋ฐฐํฌํ•˜๋˜ ์™€์ค‘ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค. Mysql์„ ์„ค์น˜ํ•˜์ง€ ์•Š๊ณ ์„œ๋„, ์ €๋ฒˆ์— ๋ฐฐํฌ๋ฅผ ์„ฑ๊ณตํ–ˆ์—ˆ๊ธฐ ๋•Œ๋ฌธ์— ์ด์œ ๋ฅผ ์•Œ์ง€ ๋ชปํ•˜์˜€๋‹ค. Mysql์„ ๋‹ค์šด ๋ฐ›์•„๋ณด๊ณ , mysql์„ ๋‹ค์šด๋ฐ›์œผ๋‹ˆ localhost์— ์ ‘๊ทผ์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค๋Š” ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค. ์ง€๋‚œ ๋ฐฐํฌ ๋•Œ์—๋Š” ๋”ฐ๋กœ mysql์„ ๋‹ค์šด ๋ฐ›์ง€ ์•Š๊ณ ๋„, ์œ„์™€ ๊ฐ™์€ ์—..
์„œ๋ฒ„์—์„œ ๋ฐฐํฌ๋ฅผ ํ•˜๊ฒŒ ๋˜๋ฉด redis๊ฐ€ ๋‹ค์šด์ด ๋˜์–ด ์žˆ์ง€ ์•Š์•„ ์—๋Ÿฌ ์ฝ”๋“œ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค. redis๋ฅผ ์ด์šฉํ•œ ๋กœ๊ทธ์•„์›ƒ์„ ๊ตฌํ˜„ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ubuntu server ํ™˜๊ฒฝ์—์„œ ๋‹ค์šด์„ ๋ฐ›์•„ ์—๋Ÿฌ๋ฅผ ํ•ด๊ฒฐํ•ด์ค˜์•ผ ํ•œ๋‹ค. sudo add-apt-repository ppa:redislabs/redis sudo apt-get update sudo apt-get install redis ์ดํ›„ redis์˜ port๊ฐ€ ์ž˜ ์‹คํ–‰๋˜๊ณ  ์žˆ๋Š”์ง€ ํ™•์ธํ•ด๋ณด๋ฉด apt install net-tools netstat -ntlp | grep 6379 ์ž˜ ์ผœ์ ธ ์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด๋Ÿผ์—๋„ ์„œ๋ฒ„ ๋‚ด์˜ spring ํ”„๋กœ์ ํŠธ์—์„œ redis ์™€ ๊ด€๋ จ๋œ ์—๋Ÿฌ๊ฐ€ ๋‚œ๋‹ค๋ฉด, spring project applicaiton.properties, or yml..
์•ฑ ๋Ÿฐ์นญ ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๋ฉด์„œ, ๋กœ๊ทธ์•„์›ƒ api๋ฅผ ์ƒ์„ฑํ–ˆ๋‹ค. JWT๋กœ User์˜ ์ •๋ณด๋ฅผ ์ ‘๊ทผํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ–ˆ๊ธฐ ๋•Œ๋ฌธ์—, ๋กœ๊ทธ์•„์›ƒ์„ ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” AccessToken์˜ ์‹œ๊ฐ„์„ ๋งŒ๋ฃŒํ•ด์•ผํ–ˆ๋‹ค. ์ƒ์„ฑํ•œ Token์„ ๋งŒ๋ฃŒํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” Redis๋ฅผ ์‚ฌ์šฉํ•ด์•ผํ•œ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ๊ฒŒ ๋˜์—ˆ๊ณ , ๋ธ”๋กœ๊ทธ์— ์ž‘์„ฑํ•˜๋ฉฐ ๋ณต์Šตํ•ด๋ณด๊ณ ์ž ํ•œ๋‹ค. 1. build.gradle implementation 'org.springframework.boot:spring-boot-starter-data-redis' build.gradle์— ์œ„์™€ ๊ฐ™์€ dependencies ์ถ”๊ฐ€ 2. RedisRepositoryConfig @RequiredArgsConstructor @Configuration @EnableRedisRepositories public c..
spring security๋ฅผ ๊ณต๋ถ€ํ•˜๊ณ ์ž, spring boot file์„ ์ƒ์„ฑํ•˜์˜€๋Š”๋ฐ build ์‹œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๋‹ค. ํ”„๋กœ์ ํŠธ ๋ฒ„์ „์ด 17์ด์–ด์„œ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๊ณ , 11๋กœ downgrade๋ฅผ ํ•ด์ฃผ์–ด์„œ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜์˜€๋‹ค. # build.gradle file ์ˆ˜์ • group = 'com.example' version = '0.0.1-SNAPSHOT' sourceCompatibility = '17' ----------------------------------------------- group = 'com.example' version = '0.0.1-SNAPSHOT' sourceCompatibility = '11' #๋ณ€๊ฒฝ
์ง€๋‚œ UMC 1๊ธฐ ์•ฑ ๊ฐœ๋ฐœ ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๋ฉด์„œ ์‚ฌ์šฉํ•œ ๊ตฌ์กฐ์— ๋Œ€ํ•ด์„œ ๊ฐ„๋‹จํ•˜๊ฒŒ ์ •๋ฆฌํ•ด๋ณด๊ณ ์ž ํ•œ๋‹ค. ์ปจํŠธ๋กค๋Ÿฌ: ์›น MVC(Model, View, Controller)์˜ ์ปจํŠธ๋กค๋Ÿฌ ์—ญํ•  ์„œ๋น„์Šค: ํ•ต์‹ฌ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง ๊ตฌํ˜„ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ: ๋ฐ์ดํ„ฐ ๋ฒ ์ด์Šค์— ์ ‘๊ทผ, ๋„๋ฉ”์ธ ๊ฐ์ฒด๋ฅผ DB์— ์ €์žฅํ•˜๊ณ  ๊ฐ„๋ฆฌ ๋„๋ฉ”์ธ: ๋น„์ฆˆ๋‹ˆ์Šค ๋„๋ฉ”์ธ ๊ฐ์ฒด ์˜ˆ) ํšŒ์›, ์ฃผ๋ฌธ, ์ฟ ํฐ, ๋“ฑ๋“ฑ ์ฃผ๋กœ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์— ์ €์žฅํ•˜๊ณ  ๊ด€๋ฆฌ๋จ
# ํ”„๋กœ์ ํŠธ ํŒŒ์ผ๋กœ ์ด๋™ cd //project file path # ๋นŒ๋“œ ์ œ๊ฑฐ ํ›„ ๋นŒ๋“œ gradlew clean build # ๋นŒ๋“œ # gradlew.bat ํŒŒ์ผ ์‹คํ–‰ ๋ช…๋ น์–ด $gradlew build # ์‹คํ–‰ํ•˜๊ธฐ java -jar (ํ”„๋กœ์ ํŠธ ๋ช…)-0.0.1-SNAPSHOT.jar ํ”„๋กœ์ ํŠธ ์‹คํ–‰ํ•˜๊ธฐ์œ„ํ•œ ํŒŒ์ผ์€ ํ”„๋กœ์ ํŠธํŒŒ์ผ/build/libs์— ๋“ค์–ด์žˆ๋‹ค. path๋กœ ์ด๋™ํ•˜์—ฌ java -jar + ์ด๋ฅผ ๋ณต์‚ฌ, ๋ถ™์—ฌ๋„ฃ๊ธฐ ํ•ด์ฃผ๋ฉด ๋œ๋‹ค.
์œ„ ์‚ฌ์ดํŠธ์—์„œ ์›ํ•˜๋Š” Project, dependencies๋ฅผ ์„ ํƒํ•œ ํ›„, Generate๋ฅผ ํ•˜๊ฒŒ ๋˜๋ฉด zipํŒŒ์ผ์„ ๋‹ค์šด ๋ฐ›๊ฒŒ ๋œ๋‹ค. ์••์ถ•์„ ํ’€๊ณ  ์›ํ•˜๋Š” IDE์—์„œ ํ”„๋กœ๊ทธ๋žจ(build gradle ํŒŒ์ผ)์„ ์—ด๋ฉด ๋œ๋‹ค. ๋‚˜๋Š” Intellj๋ฅผ ์‚ฌ์šฉํ•˜๊ณ ์ž ํ•œ๋‹ค. ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒ์„ฑํ•œ ํ›„, build gradle ํŒŒ์ผ์„ ๋ณด๋ฉด ์„ ํƒํ•œ dependencies๊ฐ€ ๋“ค์–ด์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. ํ”„๋กœ์ ํŠธ๋ฅผ run ํ•˜๊ฒŒ ๋˜๋ฉด localhost:8080์„ ํ†ตํ•ด ์œ„ ํ™”๋ฉด์ด ๋‚˜ํƒ€๋‚˜๊ฒŒ ๋œ๋‹ค. ์ด๋Ÿผ ์„ฑ๊ณต์ด๋‹ค.
์•ฑ ๊ฐœ๋ฐœ ํ”„๋กœ์ ํŠธ๋ฅผ ํ•˜๋ฉด์„œ User๊ฐ€ ์“ด ๊ธ€์„ ๋ถˆ๋Ÿฌ์˜ฌ ๋•Œ, ๋ชจ๋“  ๊ธ€์ด ๋ถˆ๋Ÿฌ์™€์ง€๊ฒŒ ๋˜๊ธฐ ๋•Œ๋ฌธ์— ์ผ์ • ๋ถ€๋ถ„์˜ ๊ธ€๋งŒ ๋ถˆ๋Ÿฌ์™€์ง€๊ฒŒ api๋ฅผ ์ˆ˜์ •ํ•ด๋‹ฌ๋ผ๋Š” ๋ถ€ํƒ์„ ๋ฐ›์•˜๋‹ค. ์ธํ„ฐ๋„ท์— ์ฐพ์•„๋ณด๋‹ˆ, FrontEnd์˜ ์—ญํ• ์ธ ๊ฒƒ ๊ฐ™์•˜์ง€๋งŒ ์ผ๋‹จ ์•Œ๊ฒ ๋‹ค๊ณ  ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ์ตœ๋Œ€ํ•œ api๋ฅผ ์ˆ˜์ •ํ•ด๋ณด๊ณ ์žํ–ˆ๋‹ค. (์•ž์œผ๋กœ๋Š” ์ด๊ฒŒ ์„œ๋ฒ„์˜ ์—ญํ• ์ธ์ง€, ํ”„๋ก ํŠธ์˜ ์—ญํ• ์ธ์ง€ ๋‹ค์‹œ ํ™•์ธํ•œ ํ›„ api๋ฅผ ์ƒ์„ฑํ•ด์•ผ๊ฒ ๋‹ค) Jpa Repository๋ฅผ ํ†ตํ•ด์„œ User๊ฐ€ ์“ด ๊ธ€์˜ ๊ฐ’์„ ๋ถˆ๋Ÿฌ์˜ค๊ฒŒ ๋œ๋‹ค. ์ด๋•Œ, Return variable์ด List๊ฐ€ ๋˜๋ฏ€๋กœ ๊ฐ’์„ ๋ณ€๊ฒฝํ•˜๋Š”๋ฐ for๋ฌธ์„ ์‚ฌ์šฉํ•ด์„œ List์— ์žˆ๋Š” ๊ฐ’์„ ๋˜๋‹ค๋ฅธ List๋กœ ์˜ฎ๊ฒจ์•ผํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋ณต์žกํ•œ ๋ฐ˜๋ณต๋ฌธ์ด ์‚ฌ์šฉ๋  ๊ฒƒ์œผ๋กœ ์˜ˆ์ƒ๋˜์—ˆ๋‹ค. for๋ฌธ์œผ๋กœ List๋ฅผ ๋˜ ๋‹ค๋ฅธ List๋กœ ์˜ฎ๊ธฐ๋ฉด์„œ ์•ˆ์— ์žˆ๋Š” ๊ฐ’์„ ๋ณ€๊ฒฝํ•˜๋Š”..
chaerlo127
'Backend Language' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (2 Page)