Skip to content

Commit 4ddf1b0

Browse files
authored
[#30] Nginx 인증서 심볼릭 링크 문제 해결 (#38)
1 parent b0ff878 commit 4ddf1b0

3 files changed

Lines changed: 19 additions & 10 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ jobs:
124124
host: ${{ secrets.SERVER_HOST }}
125125
username: root
126126
password: ${{ secrets.SERVER_PASSWORD }}
127-
source: "docker-compose.yml,nginx/nginx.conf,nginx/proxy.conf"
127+
source: "docker-compose.yml,nginx/nginx.conf.template,nginx/proxy.conf"
128128
target: "~/retoday"
129129
overwrite: true
130130

@@ -133,15 +133,19 @@ jobs:
133133
env:
134134
DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }}
135135
SHA: ${{ needs.build-and-push.outputs.sha }}
136+
DOMAIN: dev.re-today.com
136137
with:
137138
host: ${{ secrets.SERVER_HOST }}
138139
username: root
139140
password: ${{ secrets.SERVER_PASSWORD }}
140-
envs: DOCKER_USER,SHA
141+
envs: DOCKER_USER,SHA,DOMAIN
141142
script: |
142143
set -e
143144
cd ~/retoday
144145
146+
export DOMAIN="${DOMAIN}"
147+
envsubst '${DOMAIN}' < nginx/nginx.conf.template > nginx/nginx.conf
148+
145149
docker pull ${DOCKER_USER}/retoday-api:${SHA}
146150
docker tag ${DOCKER_USER}/retoday-api:${SHA} retoday-api:latest
147151
COMPOSE_PROFILES=dev docker compose up -d --force-recreate api
@@ -212,7 +216,7 @@ jobs:
212216
host: ${{ secrets.SERVER_HOST }}
213217
username: root
214218
password: ${{ secrets.SERVER_PASSWORD }}
215-
source: "docker-compose.yml,nginx/nginx.conf,nginx/proxy.conf"
219+
source: "docker-compose.yml,nginx/nginx.conf.template,nginx/proxy.conf"
216220
target: "~/retoday"
217221
overwrite: true
218222

@@ -221,15 +225,19 @@ jobs:
221225
env:
222226
DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }}
223227
SHA: ${{ needs.build-and-push.outputs.sha }}
228+
DOMAIN: api.re-today.com
224229
with:
225230
host: ${{ secrets.SERVER_HOST }}
226231
username: root
227232
password: ${{ secrets.SERVER_PASSWORD }}
228-
envs: DOCKER_USER,SHA
233+
envs: DOCKER_USER,SHA,DOMAIN
229234
script: |
230235
set -e
231236
cd ~/retoday
232237
238+
export DOMAIN="${DOMAIN}"
239+
envsubst '${DOMAIN}' < nginx/nginx.conf.template > nginx/nginx.conf
240+
233241
# 활성 컨테이너 확인
234242
if grep -q "api-blue" nginx/upstream.conf; then
235243
CURRENT="blue"; TARGET="green"

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ services:
7575
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
7676
- ./nginx/proxy.conf:/etc/nginx/proxy.conf:ro
7777
- ./nginx/upstream.conf:/etc/nginx/upstream.conf
78-
- ${NGINX_CERT_DIR}:/etc/nginx/certs:ro
78+
- /etc/letsencrypt:/etc/letsencrypt:ro
7979
- /var/www/certbot:/var/www/certbot:ro
8080
restart: unless-stopped
8181
healthcheck:
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ http {
3535

3636
server {
3737
listen 80;
38-
server_name api.re-today.com dev.re-today.com;
38+
server_name ${DOMAIN};
3939
limit_conn conn 100;
4040

4141
location = /actuator/health {
@@ -56,11 +56,12 @@ http {
5656
}
5757

5858
server {
59-
listen 443 ssl http2;
60-
server_name api.re-today.com dev.re-today.com;
59+
listen 443 ssl;
60+
server_name ${DOMAIN};
61+
http2 on;
6162

62-
ssl_certificate /etc/nginx/certs/fullchain.pem;
63-
ssl_certificate_key /etc/nginx/certs/privkey.pem;
63+
ssl_certificate /etc/letsencrypt/live/${DOMAIN}/fullchain.pem;
64+
ssl_certificate_key /etc/letsencrypt/live/${DOMAIN}/privkey.pem;
6465
ssl_protocols TLSv1.2 TLSv1.3;
6566
ssl_ciphers 'ECDHE+AESGCM:ECDHE+CHACHA20:!aNULL:!MD5:!RC4:!3DES';
6667
ssl_prefer_server_ciphers on;

0 commit comments

Comments
 (0)