Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
L-U-Ready committed Nov 22, 2024
2 parents d54cc34 + 7be93d5 commit feea7c0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
17 changes: 4 additions & 13 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ server {
proxy_set_header X-Forwarded-Proto $scheme;
}

# CORS를 위한 OPTIONS 요청 처리
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' 'http://localhost:5173'; # CORS 허용 출처
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; # 허용되는 메서드
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization'; # 허용되는 헤더
add_header 'Access-Control-Max-Age' 3600; # 프리플라이트 요청의 캐시 시간
return 204; # OPTIONS 요청에 대해 204 No Content 응답
}

# 나머지 HTTP 요청을 HTTPS로 리디렉션
location / {
return 301 https://$host$request_uri;
Expand All @@ -29,13 +20,13 @@ server {
server {
listen 443 ssl;
server_name the-monitor.o-r.kr;
ssl_certificate /etc/nginx/ssl/certificate.crt;
ssl_certificate_key /etc/nginx/ssl/private.key;
ssl_trusted_certificate /etc/nginx/ssl/ca_bundle.crt;
ssl_certificate /etc/nginx/ssl/certificate.crt; # SSL 인증서 파일 경로
ssl_certificate_key /etc/nginx/ssl/private.key; # 개인 키 파일 경로
ssl_trusted_certificate /etc/nginx/ssl/ca_bundle.crt; # 중간 인증서 경로

# Swagger UI를 포함한 모든 요청을 HTTPS로 처리
location / {
proxy_pass http://app:8080;
proxy_pass http://app:8080; # app 컨테이너로 요청을 전달
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/the_monitor/common/Config/SwaggerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public OpenAPI openAPI() {
.info(apiInfo())
.addSecurityItem(new SecurityRequirement().addList("bearerAuth"))
.addServersItem(new Server().url("http://the-monitor.o-r.kr").description("HTTP Server"))
.addServersItem(new Server().url("https://the-monitor.o-r.kr").description("HTTPS Server"));
.addServersItem(new Server().url("https://the-monitor.o-r.kr").description("HTTPS Server"))
.addServersItem(new Server().url("http://localhost:8080").description("Local Development Server"));

}

private Info apiInfo() {
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/the_monitor/common/Config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public WebConfig(OctetStreamReadMsgConverter octetStreamReadMsgConverter) {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("https://the-monitor.o-r.kr", "http://localhost:5173")
.allowedOrigins("https://the-monitor.o-r.kr",
"http://the-monitor.o-r.kr",
"http://localhost:5173",
"http://localhost:8080")
.allowedMethods("*")
.allowedHeaders("*")
.allowCredentials(true)
Expand Down

0 comments on commit feea7c0

Please sign in to comment.