1 parent 918b65b commit 80e8094Copy full SHA for 80e8094
1 file changed
deploy/fix_nginx.py
@@ -0,0 +1,24 @@
1
+import re
2
+
3
+with open('/etc/nginx/sites-enabled/testpilot', 'r') as f:
4
+ content = f.read()
5
6
+auth_block = ''' # Auth 直接代理(插件直连,路径映射到 /api/v1/auth/)
7
+ location /auth/ {
8
+ proxy_pass http://127.0.0.1:8900/api/v1/auth/;
9
+ proxy_set_header Host $host;
10
+ proxy_set_header X-Real-IP $remote_addr;
11
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
12
+ proxy_set_header X-Forwarded-Proto $scheme;
13
+ proxy_read_timeout 120s;
14
+ }
15
16
+ '''
17
18
+if 'location /auth/' not in content:
19
+ content = content.replace(' # API 代理', auth_block + ' # API 代理')
20
+ with open('/etc/nginx/sites-enabled/testpilot', 'w') as f:
21
+ f.write(content)
22
+ print("OK: /auth/ block added")
23
+else:
24
+ print("SKIP: already exists")
0 commit comments