-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb.config
More file actions
114 lines (98 loc) · 4.45 KB
/
Copy pathweb.config
File metadata and controls
114 lines (98 loc) · 4.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?xml version="1.0" encoding="UTF-8"?>
<!--
IIS 단일 사이트 설정: Frontend(정적파일) + Backend(Flask API 리버스 프록시)
사전 요구사항:
1. IIS URL Rewrite 모듈 설치
2. IIS ARR (Application Request Routing) 모듈 설치
3. IIS Manager > 서버 노드 > ARR > Server Proxy Settings > "Enable proxy" 체크
4. Flask 백엔드가 실행 중이어야 함 (아래 BACKEND_HOST/BACKEND_PORT와 일치)
★ 백엔드 주소 변경 방법
아래 <rewriteMap name="Settings"> 안의 BACKEND_BASE_URL 값만 수정하면
모든 API 프록시 규칙이 자동으로 새 주소를 사용합니다. 한 곳만 바꾸면 끝.
배포 위치:
이 web.config 파일은 IIS 사이트의 물리 경로 루트(즉, dist/index.html과 같은 폴더)에
배치되어야 합니다. 일반적으로 deploy_iis.bat 실행 후 dist/web.config가 됩니다.
-->
<configuration>
<system.webServer>
<rewrite>
<!--
★ 설정값 정의 (Rewrite Map)
BACKEND_BASE_URL의 value만 바꾸면 아래 모든 규칙이 새 주소로 프록시합니다.
예) http://192.168.0.10:5000 / http://backend.internal:8080
-->
<rewriteMaps>
<rewriteMap name="Settings">
<add key="BACKEND_BASE_URL" value="http://127.0.0.1:5000" />
</rewriteMap>
</rewriteMaps>
<rules>
<!-- /auth/* → Flask -->
<rule name="API - auth" stopProcessing="true">
<match url="^auth/(.*)" />
<action type="Rewrite" url="{Settings:BACKEND_BASE_URL}/auth/{R:1}" />
</rule>
<!-- /dashboard/* → Flask -->
<rule name="API - dashboard" stopProcessing="true">
<match url="^dashboard/(.*)" />
<action type="Rewrite" url="{Settings:BACKEND_BASE_URL}/dashboard/{R:1}" />
</rule>
<!-- /health → Flask -->
<rule name="API - health" stopProcessing="true">
<match url="^health$" />
<action type="Rewrite" url="{Settings:BACKEND_BASE_URL}/health" />
</rule>
<!-- /logs/* → Flask -->
<rule name="API - logs" stopProcessing="true">
<match url="^logs(.*)" />
<action type="Rewrite" url="{Settings:BACKEND_BASE_URL}/logs{R:1}" />
</rule>
<!-- /api/* → Flask (동적 SQL 엔드포인트) -->
<rule name="API - dynamic endpoints" stopProcessing="true">
<match url="^api/(.*)" />
<action type="Rewrite" url="{Settings:BACKEND_BASE_URL}/api/{R:1}" />
</rule>
<!-- /admin/* → Flask (admin 사용자 관리: /admin/users, /admin/users/<name>) -->
<rule name="API - admin" stopProcessing="true">
<match url="^admin/(.*)" />
<action type="Rewrite" url="{Settings:BACKEND_BASE_URL}/admin/{R:1}" />
</rule>
<!--
★ 신규 BE prefix 추가 시 주의:
Flask 에 새 라우트 prefix (예: /metrics/, /export/) 를 추가하면
반드시 여기 SPA fallback 위에 동일 패턴의 rewrite rule 을 추가할 것.
누락 시 GET 은 index.html (HTML) 이 응답되어 FE 가 JSON parse 실패하고,
POST/PUT/DELETE 는 405 Method Not Allowed 가 발생함.
-->
<!-- SPA fallback - 실제 파일이 아닌 모든 요청 → index.html -->
<rule name="SPA fallback" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>
<!-- 정적 파일 MIME 타입 -->
<staticContent>
<remove fileExtension=".js" />
<mimeMap fileExtension=".js" mimeType="application/javascript" />
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="application/json" />
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="font/woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff2" mimeType="font/woff2" />
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
<defaultDocument>
<files>
<clear />
<add value="index.html" />
</files>
</defaultDocument>
</system.webServer>
</configuration>