Skip to content

Commit ea88de9

Browse files
committed
백엔드 서버 https 인증서 배포
1 parent cab6118 commit ea88de9

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

.github/workflows/release.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,41 @@ jobs:
2222
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
2323
aws-region: ap-northeast-2
2424

25+
- name: Setup Nginx and SSL
26+
uses: appleboy/ssh-action@master
27+
with:
28+
host: ${{ secrets.EC2_HOST }}
29+
username: ubuntu
30+
key: ${{ secrets.EC2_SSH_KEY }}
31+
script: |
32+
if ! command -v nginx &> /dev/null; then
33+
sudo apt update
34+
sudo apt install -y nginx certbot python3-certbot-nginx
35+
fi
36+
37+
sudo tee /etc/nginx/sites-available/default << 'EOF'
38+
server {
39+
listen 80;
40+
listen [::]:80;
41+
server_name api-loa-life.duckdns.org;
42+
43+
location / {
44+
proxy_pass http://localhost:3001;
45+
proxy_http_version 1.1;
46+
proxy_set_header Upgrade $http_upgrade;
47+
proxy_set_header Connection 'upgrade';
48+
proxy_set_header Host $host;
49+
proxy_cache_bypass $http_upgrade;
50+
}
51+
}
52+
EOF
53+
54+
if [ ! -d "/etc/letsencrypt/live/api-loa-life.duckdns.org" ]; then
55+
sudo certbot --nginx -d api-loa-life.duckdns.org --non-interactive --agree-tos --email ${{ secrets.CERTBOT_EMAIL }}
56+
fi
57+
58+
sudo systemctl reload nginx
59+
2560
- name: Build and Deploy Backend
2661
uses: appleboy/ssh-action@master
2762
with:
@@ -38,7 +73,7 @@ jobs:
3873
3974
docker run -d \
4075
--name backend-service \
41-
-p 3000:3000 \
76+
-p 3001:3001 \
4277
-e DATABASE_URL="${{ secrets.DATABASE_URL }}" \
4378
-e GOOGLE_CLIENT_ID="${{ secrets.GOOGLE_CLIENT_ID }}" \
4479
-e GOOGLE_CLIENT_SECRET="${{ secrets.GOOGLE_CLIENT_SECRET }}" \

0 commit comments

Comments
 (0)