From 8e4cc3a7964b30a1df78db23f735516dcb0798fd Mon Sep 17 00:00:00 2001 From: Dev Uni Date: Thu, 30 Nov 2023 22:59:59 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20infra=20=EB=94=94=EB=A0=89=ED=86=A0?= =?UTF-8?q?=EB=A6=AC=20=EC=83=9D=EC=84=B1=20=EB=B0=8F=20=EB=A6=AC=ED=8C=A9?= =?UTF-8?q?=ED=84=B0=EB=A7=81=20(#208)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: infra 디렉토리 생성 및 리팩터링 * fix: 초기 아이템 데이터 이미지 링크 수정 * fix: DockerFile 경로 수정 * fix: 쉘 스크립트 경로 수정 * feat: nginx 로깅 추가 * feat: actuator 외부 차단 --- infra/nginx/templates/ssl-server.template | 6 ++++++ infra/scripts/deploy-dev.sh | 8 ++++---- infra/scripts/init-letsencrypt.sh | 6 +++--- infra/scripts/init-nginx-converter.sh | 10 +++++----- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/infra/nginx/templates/ssl-server.template b/infra/nginx/templates/ssl-server.template index 8bd2f677..3fdca313 100644 --- a/infra/nginx/templates/ssl-server.template +++ b/infra/nginx/templates/ssl-server.template @@ -1,7 +1,13 @@ server { listen 443 ssl; server_name ${SERVER_DOMAIN}; + access_log /home/ubuntu/moabam/logs/access_ssl_moabam.log main; + error_log /home/ubuntu/moabam/logs/error.log error; + location ^~ /actuator { + return 404; + } + ssl_certificate /etc/letsencrypt/live/${SERVER_DOMAIN}/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/${SERVER_DOMAIN}/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; diff --git a/infra/scripts/deploy-dev.sh b/infra/scripts/deploy-dev.sh index d11b09c0..cc6debda 100644 --- a/infra/scripts/deploy-dev.sh +++ b/infra/scripts/deploy-dev.sh @@ -1,8 +1,8 @@ #!/bin/bash # .env 파일 로드 -if [ -f /home/ubuntu/moabam/.env ]; then - source /home/ubuntu/moabam/.env +if [ -f /home/ubuntu/moabam/infra/.env ]; then + source /home/ubuntu/moabam/infra/.env fi if [ $(docker ps | grep -c "nginx") -eq 0 ]; then @@ -46,8 +46,8 @@ echo "### springboot blue-green 무중단 배포 시작 ###" echo IS_BLUE=$(docker ps | grep ${BLUE_CONTAINER}) -NGINX_CONF="/home/ubuntu/moabam/nginx/nginx.conf" -UPSTREAM_CONF="/home/ubuntu/moabam/nginx/conf.d/upstream.conf" +NGINX_CONF="/home/ubuntu/moabam/infra/nginx/nginx.conf" +UPSTREAM_CONF="/home/ubuntu/moabam/infra/nginx/conf.d/upstream.conf" if [ -n "$IS_BLUE" ]; then echo "### BLUE => GREEN ###" diff --git a/infra/scripts/init-letsencrypt.sh b/infra/scripts/init-letsencrypt.sh index b9040e36..1031fd25 100644 --- a/infra/scripts/init-letsencrypt.sh +++ b/infra/scripts/init-letsencrypt.sh @@ -1,8 +1,8 @@ #!/bin/bash # .env 파일 로드 -if [ -f /home/ubuntu/moabam/.env ]; then - source /home/ubuntu/moabam/.env +if [ -f /home/ubuntu/moabam/infra/.env ]; then + source /home/ubuntu/moabam/infra/.env fi if ! [ -x "$(command -v docker-compose)" ]; then @@ -12,7 +12,7 @@ fi domains="${SERVER_DOMAIN}" rsa_key_size=4096 -data_path="/home/ubuntu/moabam/nginx/certbot" +data_path="/home/ubuntu/moabam/infra/nginx/certbot" email="${MY_EMAIL}" # Adding a valid address is strongly recommended staging=1 # Set to 1 if you're testing your setup to avoid hitting request limits diff --git a/infra/scripts/init-nginx-converter.sh b/infra/scripts/init-nginx-converter.sh index 934f88c5..861b2aeb 100644 --- a/infra/scripts/init-nginx-converter.sh +++ b/infra/scripts/init-nginx-converter.sh @@ -1,14 +1,14 @@ #!/bin/bash # .env 파일 로드 -if [ -f /home/ubuntu/moabam/.env ]; then - source /home/ubuntu/moabam/.env +if [ -f /home/ubuntu/moabam/infra/.env ]; then + source /home/ubuntu/moabam/infra/.env fi export SERVER_DOMAIN=${SERVER_DOMAIN} export SERVER_PORT=${SERVER_PORT} export BLUE_CONTAINER=${BLUE_CONTAINER} -envsubst '$SERVER_DOMAIN' < /home/ubuntu/moabam/nginx/templates/http-server.template > /home/ubuntu/moabam/nginx/conf.d/http-server.conf -envsubst '$SERVER_DOMAIN' < /home/ubuntu/moabam/nginx/templates/ssl-server.template > /home/ubuntu/moabam/nginx/conf.d/ssl-server.conf -envsubst '$BLUE_CONTAINER $SERVER_PORT' < /home/ubuntu/moabam/nginx/templates/upstream.template > /home/ubuntu/moabam/nginx/conf.d/upstream.conf +envsubst '$SERVER_DOMAIN' < /home/ubuntu/moabam/infra/nginx/templates/http-server.template > /home/ubuntu/moabam/infra/nginx/conf.d/http-server.conf +envsubst '$SERVER_DOMAIN' < /home/ubuntu/moabam/infra/nginx/templates/ssl-server.template > /home/ubuntu/moabam/infra/nginx/conf.d/ssl-server.conf +envsubst '$BLUE_CONTAINER $SERVER_PORT' < /home/ubuntu/moabam/infra/nginx/templates/upstream.template > /home/ubuntu/moabam/infra/nginx/conf.d/upstream.conf