darkfire514 commited on
Commit
c67eb4f
·
verified ·
1 Parent(s): e20f2b9

Update nginx.conf

Browse files
Files changed (1) hide show
  1. nginx.conf +21 -11
nginx.conf CHANGED
@@ -45,7 +45,6 @@ http {
45
  proxy_set_header Host $host;
46
  proxy_set_header X-Real-IP $remote_addr;
47
  proxy_set_header X-Scheme $scheme;
48
- # nginx auth_request includes headers but not body
49
  proxy_set_header Content-Length "";
50
  proxy_pass_request_body off;
51
  }
@@ -54,12 +53,11 @@ http {
54
  # Protected Resources
55
  # =========================================================
56
 
57
- # 1. Terminal (ttyd) - Root Path
58
  location / {
59
  auth_request /oauth2/auth;
60
  error_page 401 = /oauth2/sign_in;
61
 
62
- # If authenticated, pass to ttyd
63
  proxy_pass http://127.0.0.1:7681;
64
  proxy_http_version 1.1;
65
  proxy_set_header Upgrade $http_upgrade;
@@ -68,23 +66,35 @@ http {
68
  proxy_set_header X-Real-IP $remote_addr;
69
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
70
  proxy_set_header X-Forwarded-Proto $scheme;
 
 
 
 
 
 
 
 
 
71
 
72
- # Pass user info from oauth2-proxy (optional)
73
- auth_request_set $user $upstream_http_x_auth_request_user;
74
- auth_request_set $email $upstream_http_x_auth_request_email;
75
- proxy_set_header X-User $user;
76
- proxy_set_header X-Email $email;
 
 
 
 
 
77
  }
78
 
79
- # 2. Game (WASM) - /game Path
80
  location /game {
81
  auth_request /oauth2/auth;
82
  error_page 401 = /oauth2/sign_in;
83
 
84
  alias /var/www/html/game;
85
  index index.html;
86
-
87
- # WASM specific headers
88
  add_header Cross-Origin-Opener-Policy same-origin;
89
  add_header Cross-Origin-Embedder-Policy require-corp;
90
  }
 
45
  proxy_set_header Host $host;
46
  proxy_set_header X-Real-IP $remote_addr;
47
  proxy_set_header X-Scheme $scheme;
 
48
  proxy_set_header Content-Length "";
49
  proxy_pass_request_body off;
50
  }
 
53
  # Protected Resources
54
  # =========================================================
55
 
56
+ # 1. Terminal (ttyd) - Root Path /
57
  location / {
58
  auth_request /oauth2/auth;
59
  error_page 401 = /oauth2/sign_in;
60
 
 
61
  proxy_pass http://127.0.0.1:7681;
62
  proxy_http_version 1.1;
63
  proxy_set_header Upgrade $http_upgrade;
 
66
  proxy_set_header X-Real-IP $remote_addr;
67
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
68
  proxy_set_header X-Forwarded-Proto $scheme;
69
+ }
70
+
71
+ # 2. OpenClaw Dashboard - /ui/ Path
72
+ # 注意:OpenClaw 可能期望运行在根路径。如果它不支持子路径部署,
73
+ # 我们可能需要调整,或者通过重写 URL 来适配。
74
+ # 这里我们尝试将其映射到 /ui/ 并去除前缀。
75
+ location /ui/ {
76
+ auth_request /oauth2/auth;
77
+ error_page 401 = /oauth2/sign_in;
78
 
79
+ # 这里的斜杠很重要,它会把 /ui/foo 转发为 /foo
80
+ proxy_pass http://127.0.0.1:18789/;
81
+
82
+ proxy_http_version 1.1;
83
+ proxy_set_header Upgrade $http_upgrade;
84
+ proxy_set_header Connection "upgrade";
85
+ proxy_set_header Host $host;
86
+ proxy_set_header X-Real-IP $remote_addr;
87
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
88
+ proxy_set_header X-Forwarded-Proto $scheme;
89
  }
90
 
91
+ # 3. WASM Game - /game Path (保留以备不时之需)
92
  location /game {
93
  auth_request /oauth2/auth;
94
  error_page 401 = /oauth2/sign_in;
95
 
96
  alias /var/www/html/game;
97
  index index.html;
 
 
98
  add_header Cross-Origin-Opener-Policy same-origin;
99
  add_header Cross-Origin-Embedder-Policy require-corp;
100
  }