tanbushi commited on
Commit
cefac2e
·
1 Parent(s): ccf15f9
Files changed (1) hide show
  1. nginx/conf.d/default.conf +19 -4
nginx/conf.d/default.conf CHANGED
@@ -20,14 +20,27 @@ server {
20
  end
21
  }
22
 
23
- # 默认站点 - nginx主页
24
  location / {
25
- root /usr/local/openresty/nginx/html;
26
- index index.html index.htm;
 
 
 
 
27
 
28
- # 添加自定义响应头
 
 
29
  add_header X-Powered-By "OpenResty";
30
  add_header X-Auth-Type "Basic + Lua";
 
 
 
 
 
 
 
31
  }
32
 
33
  location /health {
@@ -273,6 +286,8 @@ server {
273
  add_header Access-Control-Allow-Headers "Content-Type, Authorization, X-Requested-With, Upgrade" always;
274
  }
275
 
 
 
276
  error_page 500 502 503 504 /50x.html;
277
  location = /50x.html {
278
  root /usr/local/openresty/nginx/html;
 
20
  end
21
  }
22
 
23
+ # 默认站点 - 代理所有未匹配的请求到OpenCode
24
  location / {
25
+ proxy_pass http://127.0.0.1:57860;
26
+ proxy_set_header Host $host;
27
+ proxy_set_header X-Real-IP $remote_addr;
28
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
29
+ proxy_set_header X-Forwarded-Proto $scheme;
30
+ proxy_set_header X-Forwarded-Host $host;
31
 
32
+ add_header Access-Control-Allow-Origin * always;
33
+ add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, PATCH, OPTIONS" always;
34
+ add_header Access-Control-Allow-Headers "Content-Type, Authorization, X-Requested-With, Upgrade" always;
35
  add_header X-Powered-By "OpenResty";
36
  add_header X-Auth-Type "Basic + Lua";
37
+
38
+ # 支持WebSocket和SSE
39
+ proxy_http_version 1.1;
40
+ proxy_set_header Upgrade $http_upgrade;
41
+ proxy_set_header Connection "upgrade";
42
+ proxy_buffering off;
43
+ proxy_cache off;
44
  }
45
 
46
  location /health {
 
286
  add_header Access-Control-Allow-Headers "Content-Type, Authorization, X-Requested-With, Upgrade" always;
287
  }
288
 
289
+
290
+
291
  error_page 500 502 503 504 /50x.html;
292
  location = /50x.html {
293
  root /usr/local/openresty/nginx/html;