-
Notifications
You must be signed in to change notification settings - Fork 0
[feat] AWS 배포 하기 위한 yml 관련 환경 설정 변경 #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -44,12 +44,16 @@ public PasswordEncoder passwordEncoder() { | |||||||||||||||
| public CorsConfigurationSource corsConfigurationSource() { | ||||||||||||||||
| CorsConfiguration configuration = new CorsConfiguration(); | ||||||||||||||||
|
|
||||||||||||||||
| // 프론트엔드 포트 허용 | ||||||||||||||||
| configuration.setAllowedOrigins(List.of("http://localhost:5173")); | ||||||||||||||||
| // [핵심 수정] 환경 변수에서 프론트엔드 주소를 가져오고, 없으면 로컬 주소를 기본값으로 사용 | ||||||||||||||||
| String frontendUrl = System.getenv("FRONTEND_URL"); | ||||||||||||||||
| if (frontendUrl == null) frontendUrl = "http://localhost:5173"; | ||||||||||||||||
|
|
||||||||||||||||
| // 로컬과 실제 배포 주소를 모두 허용 목록에 넣습니다. | ||||||||||||||||
| configuration.setAllowedOrigins(List.of(frontendUrl, "http://localhost:5173")); | ||||||||||||||||
|
Comment on lines
+48
to
+52
|
||||||||||||||||
|
|
||||||||||||||||
| configuration.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "OPTIONS")); | ||||||||||||||||
| configuration.setAllowedHeaders(List.of("*")); | ||||||||||||||||
| // 쿠키 전송을 위해 필수 설정 | ||||||||||||||||
| configuration.setAllowCredentials(true); | ||||||||||||||||
| configuration.setAllowCredentials(true); // 쿠키/인증정보 전송 허용 | ||||||||||||||||
|
Comment on lines
+47
to
+56
|
||||||||||||||||
|
|
||||||||||||||||
|
Comment on lines
+56
to
57
|
||||||||||||||||
| configuration.setAllowCredentials(true); // 쿠키/인증정보 전송 허용 | |
| // 운영 환경(prod)에서는 CSRF 위험을 줄이기 위해 CORS 자격 증명(쿠키 등) 전송을 비활성화합니다. | |
| // SPRING_PROFILES_ACTIVE=prod 인 경우만 false, 그 외(로컬/개발 등)는 기존 동작 유지(true). | |
| String activeProfile = System.getenv("SPRING_PROFILES_ACTIVE"); | |
| boolean allowCredentials = activeProfile == null || !"prod".equalsIgnoreCase(activeProfile.trim()); | |
| configuration.setAllowCredentials(allowCredentials); |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,13 +1,23 @@ | ||||||||||||||
| # ----- API는 local, MySQL는 Docker ----- | ||||||||||||||
| spring.datasource.url=jdbc:mysql://mysql:3306/appdb?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul | ||||||||||||||
| # 1. Database (RDS \uC5F0\uACB0\uC6A9) | ||||||||||||||
| # \uD658\uACBD \uBCC0\uC218\uAC00 \uC788\uC73C\uBA74 \uADF8 \uAC12\uC744 \uC4F0\uACE0, \uC5C6\uC73C\uBA74 \uAE30\uBCF8\uAC12(mysql:3306)\uC744 \uC0AC\uC6A9\uD558\uB3C4\uB85D \uC124\uC815\uD568 | ||||||||||||||
| spring.datasource.url=jdbc:mysql://${RDS_HOSTNAME:mysql}:${RDS_PORT:3306}/${RDS_DB_NAME:appdb}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul | ||||||||||||||
|
||||||||||||||
| spring.datasource.url=jdbc:mysql://${RDS_HOSTNAME:mysql}:${RDS_PORT:3306}/${RDS_DB_NAME:appdb}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul | |
| spring.datasource.url=jdbc:mysql://${RDS_HOSTNAME:mysql}:${RDS_PORT:3306}/${RDS_DB_NAME:appdb}?useSSL=true&requireSSL=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul |
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default Kafka bootstrap server is set to "kafka-1:29092" which matches the docker-compose.yml service name and internal port. However, this assumes the API service will always run in the same Docker network. For AWS deployment (as indicated in the PR description), this should be configured to use MSK endpoints via environment variables, which is already supported. Consider documenting this or adjusting the default value to indicate it's for local Docker environments only.
| # 4. Kafka (MSK \uB610\uB294 Cloud Kafka \uC5F0\uACB0\uC6A9) | |
| # 4. Kafka (MSK \uB610\uB294 Cloud Kafka \uC5F0\uACB0\uC6A9) | |
| # \uAE30\uBCF8\uAC12 kafka-1:29092\uB294 docker-compose.yml \uC0AC\uC6A9 \uC2DC \uB3D9\uC77C \uB124\uD2B8\uC6CC\uD06C\uC5D0\uC11C \uB3D9\uC791\uD558\uB294 \uB85C\uCEEC Docker \uD658\uACBD\uC6A9 \uC124\uC815\uC785\uB2C8\uB2E4. | |
| # AWS (MSK) \uBC0F \uC2E4\uC81C \uC6B4\uC601 \uD658\uACBD\uC5D0\uC11C\uB294 \uD544\uC218\uB85C KAFKA_BROKERS \uD658\uACBD \uBCC0\uC218\uB97C MSK \uC5D4\uB4DC\uD3EC\uC778\uD2B8\uB85C \uC124\uC815\uD574\uC57C \uD569\uB2C8\uB2E4. |
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Kafka producer and consumer serializer/deserializer configurations are missing from the prod profile. While application-local.properties includes these configurations (lines 27-35 in application-local.properties), the prod profile only specifies the bootstrap servers. This could cause runtime errors when Kafka is used in production. Add the serializer/deserializer configurations similar to those in application-local.properties.
| spring.kafka.bootstrap-servers=${KAFKA_BROKERS:kafka-1:29092} | |
| spring.kafka.bootstrap-servers=${KAFKA_BROKERS:kafka-1:29092} | |
| spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer | |
| spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer | |
| spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer | |
| spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,8 +1,11 @@ | ||||||||||
| spring.application.name=api | ||||||||||
| spring.profiles.active=local | ||||||||||
| spring.profiles.active=prod | ||||||||||
|
|
||||||||||
| # JWT \uC124\uC815 | ||||||||||
| jwt.secret=${JWT_SECRET} | ||||||||||
|
|
||||||||||
| # TMDB API \uD1A0\uD070 (\uACF5\uD1B5) | ||||||||||
| custom.tmdb.access-token=${TMDB_ACCESS_TOKEN} | ||||||||||
| custom.tmdb.access-token=${TMDB_ACCESS_TOKEN} | ||||||||||
|
|
||||||||||
| # Actuator endpoint \uBAA8\uB450 \uB178\uCD9C | ||||||||||
| management.endpoints.web.exposure.include=* | ||||||||||
|
Comment on lines
+10
to
+11
|
||||||||||
| # Actuator endpoint \uBAA8\uB450 \uB178\uCD9C | |
| management.endpoints.web.exposure.include=* | |
| # Actuator endpoint health \uB9CC \uB178\uCD9C | |
| management.endpoints.web.exposure.include=health |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,8 +1,8 @@ | ||||||
| server.port=8081 | ||||||
|
|
||||||
| spring.datasource.url=jdbc:mysql://mysql:3306/appdb?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul | ||||||
| spring.datasource.username=app | ||||||
| spring.datasource.password=app | ||||||
| spring.datasource.url=jdbc:mysql://${RDS_HOSTNAME:mysql}:${RDS_PORT:3306}/${RDS_DB_NAME:appdb}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul | ||||||
|
||||||
| spring.datasource.url=jdbc:mysql://${RDS_HOSTNAME:mysql}:${RDS_PORT:3306}/${RDS_DB_NAME:appdb}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul | |
| spring.datasource.url=jdbc:mysql://${RDS_HOSTNAME:mysql}:${RDS_PORT:3306}/${RDS_DB_NAME:appdb}?useSSL=true&requireSSL=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,48 @@ | ||
| # Nginx 전체 설정 파일 | ||
| worker_processes auto; | ||
|
|
||
| events { | ||
| worker_connections 1024; | ||
| } | ||
|
|
||
| http { | ||
| include /etc/nginx/mime.types; | ||
| default_type application/octet-stream; | ||
|
|
||
| sendfile on; | ||
| keepalive_timeout 65; | ||
|
|
||
| # 1. 기존 include는 주석 처리하거나 그대로 둡니다. | ||
| # include /etc/nginx/conf.d/*.conf; | ||
|
|
||
| # 2. 서버 설정 | ||
| server { | ||
| listen 80; | ||
|
|
||
| # 일반 API 요청 (로컬 API 서버 연결) | ||
| location /api/ { | ||
| proxy_pass http://host.docker.internal:8080; | ||
| proxy_set_header Host $host; | ||
| proxy_set_header X-Real-IP $remote_addr; | ||
| } | ||
|
|
||
| # SSE 전용 설정 (실시간 알림용) | ||
| location /api/sse { | ||
| proxy_pass http://host.docker.internal:8080; | ||
| proxy_set_header Connection ""; | ||
| proxy_http_version 1.1; | ||
| proxy_buffering off; # 새로고침 안해도 알람 전송해주는 설정 | ||
| proxy_cache off; | ||
| proxy_read_timeout 3600s; | ||
| } | ||
| } | ||
| } | ||
| events { | ||
| worker_connections 1024; | ||
| } | ||
|
|
||
| http { | ||
| include /etc/nginx/mime.types; | ||
| default_type application/octet-stream; | ||
|
|
||
| sendfile on; | ||
| keepalive_timeout 65; | ||
|
|
||
| server { | ||
| listen 80; | ||
|
|
||
| # [필수] AWS 내부 DNS 서버 주소 (Service Discovery를 찾기 위해 꼭 필요함) | ||
| resolver 10.0.0.2 valid=30s; | ||
|
||
|
|
||
| # [필수] 변수 정의: API 서버의 내부 도메인 주소 | ||
| set $api_url http://api.mopl.local:8080; | ||
|
||
|
|
||
| # 1. 일반 API 요청 | ||
| location /api/ { | ||
| proxy_pass $api_url; | ||
| proxy_set_header Host $host; | ||
| proxy_set_header X-Real-IP $remote_addr; | ||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
| } | ||
|
|
||
| # 2. SSE 전용 설정 (실시간 알림용) | ||
| location /api/sse { | ||
| proxy_pass $api_url; | ||
| proxy_set_header Connection ""; | ||
| proxy_http_version 1.1; | ||
| proxy_buffering off; | ||
| proxy_cache off; | ||
| proxy_read_timeout 3600s; | ||
| } | ||
|
|
||
| # [추가] ALB 건강 체크용 (배포 시 필수) | ||
| location /health { | ||
| access_log off; | ||
| return 200 'OK'; | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API service now uses "prod" profile while the Batch service still uses "docker" profile (line 70 in docker-compose.yml). For consistency and clarity in deployment configuration, consider aligning both services to use the same profile naming convention (either both use "prod" or both use "docker"). This inconsistency could lead to confusion about which environment is being used.