Spring Boot Admin Server, Client config 설정하기

이미지
 Spring Boot로 많은 프로젝트를 진행하게 됩니다. 많은 모니터링 도구가 있지만, Spring Boot 어플리케이션을 쉽게 모니터링 할 수 있는 방법을 소개하려고 합니다.   코드 중심으로 살펴보겠습니다. 1. 어드민 서버 구축 1-1. 디펜던시 추가 dependencies { // https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-starter-server implementation 'de.codecentric:spring-boot-admin-starter-server:2.5.4' } 1-2. 어드민 서버 설정 활성화 @SpringBootApplication @EnableAdminServer public class ServerApplication { public static void main (String[] args) { SpringApplication. run (ServerApplication. class, args) ; } } EnableAdminServer를 하면 됩니다. 2. 클라이언트 서버 설정  예제는 book-client, member-client 2가지 클라이언트, member-client가 2개의 인스턴스 실행으로 작성했습니다.  2-1 디펜던시 추가 dependencies { // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web implementation 'org.springframework.boot:spring-boot-starter-web:2.5.4' // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-actuator implementation 'org.spring...

macOS nginx 설치, 실행, 설정 위치

macOS에서 nginx을 설치하려면 Homebrew가 먼저 설치되어야 합니다.  설치 방법은 앞선 포스팅을 참고바랍니다.

https://withccm.blogspot.com/2020/12/macos-brew.html


nginx 설치

Homebrew를 설치한 이후 brew 명령어를 사용하여 nginx를 설치합니다.

brew install nginx

m1 에서 안될때

brew install nginx
Warning: No available formula with the name "nginx".
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.

위와 같은 오류 발생시 brew 코어 디렉토리를 삭제해 주면 해결됩니다.

rm -rf $(brew --repo homebrew/core)

이후 설치하는데 시간이 좀 필요합니다.


nginx 구동 명령어

nginx           # 서버 시작
nginx -s stop # 서버 정지
nginx -t # 설정 테스트
nginx -s reload # 서버 재시작


nginx -t 를 사용하면 설정 수정후 에러가 있는지 미리 확인할 수 있는 유용한 명령어 입니다.


nginx 설정파일 위치

/usr/local/etc/nginx
   or
/opt/homebrew/etc/nginx


프록시 설정하기

nginx.conf

server {
listen 80;
server_name localhost;
location / {
proxy_pass http://127.0.0.1:3000;
}
}

/ 이하의 모든 요청을 3000번 포트로 프록시 합니다.


server {
listen 80;
server_name localhost;

location /static {
root /home/withccm/abcd/static;
}

location / {
proxy_pass http://127.0.0.1:3000;
}
}

정적 파일과 서버 요청이 나누어진 예제입니다.

root는 해당 폴더의 정적 파일이 웹서버를 통해 클라이언트로 전달됩니다.


참고 문서

https://blog.naver.com/PostView.naver?blogId=sqlpro&logNo=222437059888


댓글

이 블로그의 인기 게시물

Spring boot redis cache config

Spring boot redis RedisTemplate

MySQL PK 중복 (duplicate key ) 해결 방법