Skip to content

Commit

Permalink
Merge pull request #54 from Book-Mile/env/#53
Browse files Browse the repository at this point in the history
[Env/#53] Nginx 설정 및 docker-compose 파일 내용 수정
  • Loading branch information
kingjinyong authored Jan 17, 2025
2 parents c6ecbc9 + 57d3f5f commit 4d41a16
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,29 @@ services:
networks:
- app-network

nginx:
image: nginx:latest
container_name: book-mile-nginx
restart: always
ports:
- "80:80"
- "443:443"
depends_on:
- application
volumes:
- ./nginx:/etc/nginx/conf.d
- /etc/letsencrypt:/etc/letsencrypt
networks:
- app-network

certbot:
image: certbot/certbot
container_name: certbot
volumes:
- /etc/letsencrypt:/etc/letsencrypt
- ./nginx:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do sleep 1000; done'"

volumes:
mysql_data:
redis_data:
Expand Down
31 changes: 31 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# HTTP에서 HTTPS로 리다이렉트
server {
listen 80;
server_name bookmile.site www.bookmile.site;

location / {
return 301 https://$host$request_uri;
}
}

# HTTPS 설정
server {
listen 443 ssl;
server_name bookmile.site www.bookmile.site;

# SSL 인증서 경로 (Let's Encrypt 인증서)
ssl_certificate /etc/letsencrypt/live/bookmile.site/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/bookmile.site/privkey.pem;

# SSL 설정 강화
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;

# 애플리케이션 프록시
location / {
proxy_pass http://application:8080; # 'application'은 docker-compose.yml에서 정의된 서비스 이름
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

0 comments on commit 4d41a16

Please sign in to comment.