Skip to content

Commit c0426c9

Browse files
authored
chore: 호스팅 도메인 변경과 nginx 제거에 따른 전환 (#118)
* chore: nginx docker-compose에서 제거 * chore: cross-origin 허용 url 전환 * chore: nginx 제거와 docker-compose 명령 변경에 따른 workflow 수정 * feat: CorsPropertiesConfig 추가, cors allowed origins 정보를 yml로 분리한다 * style: 주석 삭제
1 parent d335cde commit c0426c9

File tree

6 files changed

+34
-36
lines changed

6 files changed

+34
-36
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,6 @@ jobs:
6363
key: ${{ secrets.PRIVATE_KEY }}
6464
source: "./docker-compose.yml"
6565
target: "/home/${{ secrets.USERNAME }}/solid-connect-server/"
66-
67-
- name: Copy nginx configuration file to remote
68-
uses: appleboy/scp-action@master
69-
with:
70-
host: ${{ secrets.HOST }}
71-
username: ${{ secrets.USERNAME }}
72-
key: ${{ secrets.PRIVATE_KEY }}
73-
source: "./nginx.conf"
74-
target: "/home/${{ secrets.USERNAME }}/solid-connect-server/"
7566

7667
- name: Run docker compose
7768
uses: appleboy/ssh-action@master
@@ -82,5 +73,5 @@ jobs:
8273
script_stop: true
8374
script: |
8475
cd /home/${{ secrets.USERNAME }}/solid-connect-server
85-
docker-compose down
86-
docker-compose up -d --build
76+
docker compose down
77+
docker compose up -d --build

docker-compose.yml

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,15 @@ services:
1717
depends_on:
1818
- redis
1919

20-
solid-connect-server:
20+
solid-connection-server:
2121
build:
2222
context: .
2323
dockerfile: Dockerfile
24-
container_name: solid-connect-server
24+
container_name: solid-connection-server
2525
ports:
2626
- "8080:8080"
2727
environment:
2828
- SPRING_DATA_REDIS_HOST=redis
2929
- SPRING_DATA_REDIS_PORT=6379
3030
depends_on:
31-
- redis
32-
33-
nginx:
34-
image: nginx:latest
35-
container_name: nginx
36-
ports:
37-
- "80:80"
38-
- "443:443"
39-
volumes:
40-
- ./nginx.conf:/etc/nginx/conf.d/default.conf
41-
- /etc/letsencrypt:/etc/letsencrypt
42-
depends_on:
43-
- solid-connect-server
31+
- redis

nginx.conf renamed to docs/nginx.conf

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ server {
33

44
# http를 사용하는 경우 주석 해제
55
# location / {
6-
# proxy_pass http://solid-connect-server:8080;
6+
# proxy_pass http://solid-connection-server:8080;
77
# proxy_set_header Host $host;
88
# proxy_set_header X-Real-IP $remote_addr;
99
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -18,8 +18,8 @@ server {
1818
server {
1919
listen 443 ssl;
2020

21-
ssl_certificate /etc/letsencrypt/live/api.solid-connect.net/fullchain.pem;
22-
ssl_certificate_key /etc/letsencrypt/live/api.solid-connect.net/privkey.pem;
21+
ssl_certificate /etc/letsencrypt/live/api.solid-connection.com/fullchain.pem;
22+
ssl_certificate_key /etc/letsencrypt/live/api.solid-connection.com/privkey.pem;
2323
client_max_body_size 10M;
2424

2525
ssl_protocols TLSv1.2 TLSv1.3;
@@ -31,14 +31,10 @@ server {
3131
ssl_stapling_verify on;
3232

3333
location / {
34-
proxy_pass http://solid-connect-server:8080;
34+
proxy_pass http://solid-connection-server:8080;
3535
proxy_set_header Host $host;
3636
proxy_set_header X-Real-IP $remote_addr;
3737
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
3838
proxy_set_header X-Forwarded-Proto $scheme;
3939
}
40-
41-
location ~ /.well-known/acme-challenge { # 인증서 갱신에 필요한 경로 설정
42-
allow all;
43-
}
4440
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.example.solidconnection.config.cors;
2+
3+
import lombok.Getter;
4+
import lombok.Setter;
5+
import org.springframework.boot.context.properties.ConfigurationProperties;
6+
import org.springframework.context.annotation.Configuration;
7+
8+
import java.util.List;
9+
10+
@Getter
11+
@Setter
12+
@ConfigurationProperties(prefix = "cors")
13+
@Configuration
14+
public class CorsPropertiesConfig {
15+
16+
private List<String> allowedOrigins;
17+
}

src/main/java/com/example/solidconnection/config/cors/WebConfig.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
package com.example.solidconnection.config.cors;
22

3+
import lombok.RequiredArgsConstructor;
34
import org.springframework.context.annotation.Configuration;
45
import org.springframework.web.servlet.config.annotation.CorsRegistry;
56
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
67

78
@Configuration
9+
@RequiredArgsConstructor
810
public class WebConfig implements WebMvcConfigurer {
911

12+
private final CorsPropertiesConfig corsProperties;
13+
1014
@Override
1115
public void addCorsMappings(CorsRegistry registry) {
1216
registry.addMapping("/**")
13-
.allowedOrigins("http://localhost:8080", "http://localhost:3000", "https://www.solid-connect.net")
17+
.allowedOrigins(corsProperties.getAllowedOrigins().toArray(new String[0]))
1418
.allowedMethods("*")
1519
.allowedHeaders("*")
1620
.allowCredentials(true);

src/main/java/com/example/solidconnection/config/security/SecurityConfiguration.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.example.solidconnection.config.security;
22

3+
import com.example.solidconnection.config.cors.CorsPropertiesConfig;
34
import lombok.RequiredArgsConstructor;
45
import org.springframework.context.annotation.Bean;
56
import org.springframework.context.annotation.Configuration;
@@ -23,11 +24,12 @@
2324
public class SecurityConfiguration {
2425

2526
private final JwtAuthenticationFilter jwtAuthenticationFilter;
27+
private final CorsPropertiesConfig corsProperties;
2628

2729
@Bean
2830
public CorsConfigurationSource corsConfigurationSource() {
2931
CorsConfiguration configuration = new CorsConfiguration();
30-
configuration.setAllowedOrigins(Arrays.asList("https://www.solid-connect.net", "http://localhost:8080", "https://www.api.solid-connect.net", "http://localhost:3000"));
32+
configuration.setAllowedOrigins(corsProperties.getAllowedOrigins());
3133
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"));
3234
configuration.setAllowedHeaders(Arrays.asList("*"));
3335
configuration.setAllowCredentials(true);

0 commit comments

Comments
 (0)