Compare commits

...

5 Commits

Author SHA1 Message Date
weli 3e78513ea3 admin: proc proxy_pass use literal 127.0.0.1:3004 (fix nginx var+URI 404)
Made-with: Cursor
2026-04-26 21:27:50 +08:00
weli 9ab2ae4753 admin: proxy /api/v1/proc to Rust htyproc (same as v2)
Made-with: Cursor
2026-04-26 21:25:34 +08:00
weli 23ce2eff19 fix(nginx): fix proxy_pass URI rewriting for /api/v2/ts/ location
nginx does not automatically handle URI appending when variables are used
in proxy_pass. Replace variable-based proxy_pass with hardcoded IP + rewrite
rules to correctly map /api/v2/ts/* → /api/v1/ts/* on the Rust htyts backend.

Symptom: all requests to /api/v2/ts/ returned 404 because the variable-based
proxy_pass sent every request to /api/v1/ts/ (root) regardless of path.
2026-04-26 20:48:49 +08:00
weli 7d47a64c11 feat: switch kc proxy route to clazz endpoint
Align admin gateway routes across environments by replacing /api/v1/kc/ upstream mapping with /api/v1/clazz/ to match current backend path semantics.

Made-with: Cursor
2026-04-26 09:28:47 +08:00
weli 0d7dd28f28 feat: /api/v2 ts/proc to Rust htyts:3003 htyproc:3004, admin routes
- ts.conf/proc.conf: v2 locations and huiwing_htyts_rust/htyproc_rust vars
- admin.conf: /api/v2/ts and /api/v2/proc on admin for same-origin tests
- local_macos proc.conf; remove duplicate conf/alchemy
- huiwings ai.conf: coze auth comment lines merged from removed alchemy copy

Made-with: Cursor
2026-03-29 11:37:16 +08:00
14 changed files with 226 additions and 97 deletions
-1
View File
@@ -1 +0,0 @@
huiwing:$apr1$r50umplo$ltopNoFz2rhNuSgKN46e0/
-69
View File
@@ -1,69 +0,0 @@
server {
# https://serverfault.com/questions/798734/use-variable-for-server-name-in-nginx#
# server_name $servername;
server_name "ai.alchemy-studio.cn";
listen 443 ssl;
# listen 80;
client_max_body_size 10M;
# disable in local test env
ssl_certificate /etc/letsencrypt/live/alchemy-studio.cn/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/alchemy-studio.cn/privkey.pem; # managed by Certbot
location / {
try_files $uri $uri/ /index.html;
proxy_set_header Host "ai.alchemy-studio.cn";
proxy_set_header X-Real-IP $remote_addr;
# disable in local test env
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $remote_addr;
}
location /api/v1/index {
return 200 "Ai api index";
}
add_header Access-Control-Allow-Origin $http_origin always;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
add_header Access-Control-Allow-Headers 'Authorization,unionid,HtySudoerToken,HtyHost,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always;
add_header Access-Control-Allow-Credentials true always;
add_header Access-Control-Max-Age 86400 always;
if ($request_method = 'OPTIONS') {
return 200;
}
location /api/v1/ai/ {
proxy_set_header Host $host;
add_header Access-Control-Allow-Origin $http_origin always;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
add_header Access-Control-Allow-Headers 'Authorization,HtyAdminToken,HtySudoerToken,HtyHost,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always;
add_header Access-Control-Allow-Credentials true always;
add_header Access-Control-Max-Age 86400 always;
if ($request_method = 'OPTIONS') {
return 200;
}
# auth_basic "ai_api access auth";
# auth_basic_user_file /usr/local/openresty/nginx/conf.d/.htpasswd;
proxy_pass http://127.0.0.1:5000/;
}
location /api/v1/coze/ {
proxy_set_header Host $host;
add_header Access-Control-Allow-Origin $http_origin always;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
add_header Access-Control-Allow-Headers 'Authorization,HtyAdminToken,HtySudoerToken,HtyHost,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always;
add_header Access-Control-Allow-Credentials true always;
add_header Access-Control-Max-Age 86400 always;
if ($request_method = 'OPTIONS') {
return 200;
}
# auth_basic "coze_api access auth";
# auth_basic_user_file /usr/local/openresty/nginx/conf.d/.htpasswd;
proxy_pass http://127.0.0.1:6000/;
}
}
+28 -3
View File
@@ -10,7 +10,8 @@ server {
ssl_certificate_key /etc/letsencrypt/live/huiwings.cn/privkey.pem; # managed by Certbot
set $tmp_file_dir "/file_upload"; # 文件存储路径
set $task_server "http://127.0.0.1:8080"; # task server host
set $task_server "http://127.0.0.1:8080"; # Java task_server
set $huiwing_htyts_rust "127.0.0.1:3003"; # huiwing 仓库 htytsRust
set $htyuc "http://127.0.0.1:3000"; #htyuc host
set $resty_loc "/usr/local/openresty";
set $convert "/usr/bin/convert";
@@ -100,8 +101,8 @@ server {
# content_by_lua_file $resty_loc/nginx/scripts/test.lua;
# }
location /api/v1/kc/ {
proxy_pass http://127.0.0.1:3002/api/v1/kc/;
location /api/v1/clazz/ {
proxy_pass http://127.0.0.1:3002/api/v1/clazz/;
}
location /api/v1/ws/ {
proxy_pass http://127.0.0.1:3001/api/v1/ws/;
@@ -109,6 +110,30 @@ server {
location /api/v1/uc/ {
proxy_pass http://127.0.0.1:3000/api/v1/uc/;
}
location /api/v1/proc/ {
proxy_pass http://127.0.0.1:3004/api/v1/proc/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# 同域独立测 Rust TS/proc(不经 ts./proc. 子域);/api/v2 → 本机 htyts/htyproc
location /api/v2/ts/ {
proxy_pass http://$huiwing_htyts_rust/api/v1/ts/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /api/v2/proc/ {
proxy_pass http://127.0.0.1:3004/api/v1/proc/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
+3
View File
@@ -61,6 +61,9 @@ server {
return 200;
}
# auth_basic "coze_api access auth";
# auth_basic_user_file /usr/local/openresty/nginx/conf.d/.htpasswd;
proxy_pass http://127.0.0.1:6000/;
}
}
+16
View File
@@ -8,6 +8,9 @@ server {
ssl_certificate /etc/letsencrypt/live/huiwings.cn/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/huiwings.cn/privkey.pem; # managed by Certbot
# huiwing 仓库:`cargo run -p htyproc`env 见 envs/*/htyproc.envPROC_PORT=3004
set $huiwing_htyproc_rust "127.0.0.1:3004";
location /api/v1/proc/ {
add_header Access-Control-Allow-Origin $http_origin always;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
@@ -19,4 +22,17 @@ server {
}
proxy_pass http://127.0.0.1:8880/api/v1/proc/;
}
# Rust htyproc:对外 /api/v2/proc → 本进程;后端路由仍为 /api/v1/proc
location /api/v2/proc/ {
add_header Access-Control-Allow-Origin $http_origin always;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
add_header Access-Control-Allow-Headers 'Authorization,HtyAdminToken,HtySudoerToken,HtyHost,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always;
add_header Access-Control-Allow-Credentials true always;
add_header Access-Control-Max-Age 86400 always;
if ($request_method = 'OPTIONS') {
return 200;
}
proxy_pass http://$huiwing_htyproc_rust/api/v1/proc/;
}
}
+17 -1
View File
@@ -10,7 +10,10 @@ server {
ssl_certificate /etc/letsencrypt/live/huiwings.cn/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/huiwings.cn/privkey.pem; # managed by Certbot
set $task_server "http://127.0.0.1:8080"; # task server host
set $task_server "http://127.0.0.1:8080"; # Java task_server
# huiwing 仓库:`cargo run -p htyts`env 见 envs/*/htyts.envTS_PORT=3003
set $huiwing_htyts_rust "127.0.0.1:3003";
set $task_server_rust "http://$huiwing_htyts_rust"; # 与 Java 并行,仅 /api/v2 走此
set $htyuc "http://127.0.0.1:3000"; #htyuc host
set $resty_loc "/usr/local/openresty";
@@ -26,6 +29,19 @@ server {
}
proxy_pass http://127.0.0.1:8080/api/v1/ts/;
}
# Rust htyts:对外 /api/v2/ts → 本进程;后端路由仍为 /api/v1/ts(与 Java /api/v1/ts 并行)
location /api/v2/ts/ {
add_header Access-Control-Allow-Origin $http_origin always;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
add_header Access-Control-Allow-Headers 'Authorization,HtyAdminToken,HtySudoerToken,HtyHost,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always;
add_header Access-Control-Allow-Credentials true always;
add_header Access-Control-Max-Age 86400 always;
if ($request_method = 'OPTIONS') {
return 200;
}
proxy_pass http://$huiwing_htyts_rust/api/v1/ts/;
}
}
# server {
+18 -1
View File
@@ -6,7 +6,9 @@ server {
client_max_body_size 10M;
set $tmp_file_dir "/file_upload"; # 文件存储路径
set $task_server "http://127.0.0.1:8080"; # task server host
set $task_server "http://127.0.0.1:8080"; # Java task_server
set $huiwing_htyts_rust "127.0.0.1:3003";
set $huiwing_htyproc_rust "127.0.0.1:3004";
set $htyuc "http://127.0.0.1:3000"; #htyuc host
set $resty_loc "/usr/local/openresty";
set $convert "/usr/local/bin/convert";
@@ -101,4 +103,19 @@ server {
location /api/v1/uc/ {
proxy_pass http://127.0.0.1:3000/api/v1/uc/;
}
location /api/v2/ts/ {
proxy_pass http://$huiwing_htyts_rust/api/v1/ts/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /api/v2/proc/ {
proxy_pass http://$huiwing_htyproc_rust/api/v1/proc/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
+15 -1
View File
@@ -5,7 +5,9 @@ server {
listen 8088;
client_max_body_size 10M;
set $task_server "http://127.0.0.1:8080"; # task server host
set $task_server "http://127.0.0.1:8080"; # Java task_server
set $huiwing_htyts_rust "127.0.0.1:3003"; # huiwing 仓库 htytsRust
set $task_server_rust "http://$huiwing_htyts_rust";
set $htyuc "http://127.0.0.1:3000"; #htyuc host
set $resty_loc "/usr/local/openresty";
@@ -20,5 +22,17 @@ server {
}
proxy_pass http://127.0.0.1:8080/api/v1/ts/;
}
location /api/v2/ts/ {
add_header Access-Control-Allow-Origin $http_origin always;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
add_header Access-Control-Allow-Headers 'Authorization,HtyAdminToken,HtySudoerToken,HtyHost,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always;
add_header Access-Control-Allow-Credentials true always;
add_header Access-Control-Max-Age 86400 always;
if ($request_method = 'OPTIONS') {
return 200;
}
proxy_pass http://$huiwing_htyts_rust/api/v1/ts/;
}
}
+20 -3
View File
@@ -6,7 +6,9 @@ server {
client_max_body_size 10M;
set $tmp_file_dir "/usr/local/file_upload"; # 文件存储路径
set $task_server "http://127.0.0.1:8080"; # task server host
set $task_server "http://127.0.0.1:8080"; # Java task_server
set $huiwing_htyts_rust "127.0.0.1:3003";
set $huiwing_htyproc_rust "127.0.0.1:3004";
# set $htyuc "http://127.0.0.1:3000"; #htyuc host
set $htyuc "https://admin.moicen.com"; #Verify jwt token
set $resty_loc "/usr/local/opt/openresty";
@@ -95,8 +97,8 @@ server {
content_by_lua_file $resty_loc/nginx/scripts/test.lua;
}
location /api/v1/kc/ {
proxy_pass http://127.0.0.1:3002/api/v1/kc/;
location /api/v1/clazz/ {
proxy_pass http://127.0.0.1:3002/api/v1/clazz/;
}
location /api/v1/ws/ {
proxy_pass http://127.0.0.1:3001/api/v1/ws/;
@@ -105,6 +107,21 @@ server {
proxy_pass http://127.0.0.1:3000/api/v1/uc/;
}
location /api/v2/ts/ {
proxy_pass http://$huiwing_htyts_rust/api/v1/ts/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /api/v2/proc/ {
proxy_pass http://$huiwing_htyproc_rust/api/v1/proc/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /api/ngx/upyun_download {
content_by_lua_file $resty_loc/nginx/scripts/upyun_download.lua;
}
+31
View File
@@ -0,0 +1,31 @@
server {
server_name "proc.localhost";
listen 8088;
client_max_body_size 10M;
set $huiwing_htyproc_rust "127.0.0.1:3004"; # huiwing 仓库 htyprocRust
location /api/v1/proc/ {
add_header Access-Control-Allow-Origin $http_origin always;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
add_header Access-Control-Allow-Headers 'Authorization,HtyAdminToken,HtySudoerToken,HtyHost,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always;
add_header Access-Control-Allow-Credentials true always;
add_header Access-Control-Max-Age 86400 always;
if ($request_method = 'OPTIONS') {
return 200;
}
proxy_pass http://127.0.0.1:8880/api/v1/proc/;
}
location /api/v2/proc/ {
add_header Access-Control-Allow-Origin $http_origin always;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
add_header Access-Control-Allow-Headers 'Authorization,HtyAdminToken,HtySudoerToken,HtyHost,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always;
add_header Access-Control-Allow-Credentials true always;
add_header Access-Control-Max-Age 86400 always;
if ($request_method = 'OPTIONS') {
return 200;
}
proxy_pass http://$huiwing_htyproc_rust/api/v1/proc/;
}
}
+15 -1
View File
@@ -5,7 +5,9 @@ server {
listen 8088;
client_max_body_size 10M;
set $task_server "http://127.0.0.1:8080"; # task server host
set $task_server "http://127.0.0.1:8080"; # Java task_server
set $huiwing_htyts_rust "127.0.0.1:3003"; # huiwing 仓库 htytsRust
set $task_server_rust "http://$huiwing_htyts_rust";
set $htyuc "http://127.0.0.1:3000"; #htyuc host
set $resty_loc "/usr/local/opt/openresty";
@@ -20,5 +22,17 @@ server {
}
proxy_pass http://127.0.0.1:8080/api/v1/ts/;
}
location /api/v2/ts/ {
add_header Access-Control-Allow-Origin $http_origin always;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
add_header Access-Control-Allow-Headers 'Authorization,HtyAdminToken,HtySudoerToken,HtyHost,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always;
add_header Access-Control-Allow-Credentials true always;
add_header Access-Control-Max-Age 86400 always;
if ($request_method = 'OPTIONS') {
return 200;
}
proxy_pass http://$huiwing_htyts_rust/api/v1/ts/;
}
}
+29 -1
View File
@@ -31,7 +31,8 @@ server {
ssl_certificate_key /etc/letsencrypt/live/moicen.com/privkey.pem; # managed by Certbot
set $tmp_file_dir "/file_upload"; # 文件存储路径
set $task_server "http://127.0.0.1:8080"; # task server host
set $task_server "http://127.0.0.1:8080"; # Java task_server
set $huiwing_htyts_rust "127.0.0.1:3003";
set $htyuc "http://127.0.0.1:3000"; #htyuc host
set $resty_loc "/usr/local/openresty";
set $convert "/usr/bin/convert";
@@ -133,6 +134,33 @@ server {
location /api/v1/uc/ {
proxy_pass http://127.0.0.1:3000/api/v1/uc/;
}
# 管理端历史路径 /api/v1/proc/*(与 /api/v2/proc/ 同 upstream Rust htyproc
# 勿在 proxy_pass 的 host 段使用变量 + URI 路径组合,否则 nginx 可能不把 URI 正确传给 axum(对端 404)。
location /api/v1/proc/ {
proxy_pass http://127.0.0.1:3004/api/v1/proc/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /api/v2/ts/ {
rewrite ^/api/v2/ts/$ /api/v1/ts break;
rewrite ^/api/v2/ts/(.+)$ /api/v1/ts/$1 break;
proxy_pass http://127.0.0.1:3003;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /api/v2/proc/ {
proxy_pass http://127.0.0.1:3004/api/v1/proc/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
+14
View File
@@ -8,6 +8,8 @@ server {
ssl_certificate /etc/letsencrypt/live/moicen.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/moicen.com/privkey.pem; # managed by Certbot
set $huiwing_htyproc_rust "127.0.0.1:3004"; # huiwing 仓库 htyprocRust
location /api/v1/proc/ {
add_header Access-Control-Allow-Origin $http_origin always;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
@@ -19,4 +21,16 @@ server {
}
proxy_pass http://127.0.0.1:8880/api/v1/proc/;
}
location /api/v2/proc/ {
add_header Access-Control-Allow-Origin $http_origin always;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
add_header Access-Control-Allow-Headers 'Authorization,HtyAdminToken,HtySudoerToken,HtyHost,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always;
add_header Access-Control-Allow-Credentials true always;
add_header Access-Control-Max-Age 86400 always;
if ($request_method = 'OPTIONS') {
return 200;
}
proxy_pass http://$huiwing_htyproc_rust/api/v1/proc/;
}
}
+20 -16
View File
@@ -1,21 +1,19 @@
server {
# https://serverfault.com/questions/798734/use-variable-for-server-name-in-nginx#
# server_name $servername;
server_name "ts.moicen.com";
listen 443 ssl;
listen 80;
client_max_body_size 10M;
# disable in local test env
ssl_certificate /etc/letsencrypt/live/moicen.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/moicen.com/privkey.pem; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/moicen.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/moicen.com/privkey.pem;
set $task_server "http://127.0.0.1:8080"; # task server host
set $htyuc "http://127.0.0.1:3000"; #htyuc host
set $task_server "http://127.0.0.1:8080";
set $huiwing_htyts_rust "127.0.0.1:3003";
set $task_server_rust "http://$huiwing_htyts_rust";
set $htyuc "http://127.0.0.1:3000";
set $resty_loc "/usr/local/openresty";
location /api/v1/ts/ {
add_header Access-Control-Allow-Origin $http_origin always;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
add_header Access-Control-Allow-Headers 'Authorization,HtyAdminToken,HtySudoerToken,HtyHost,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always;
@@ -26,12 +24,18 @@ server {
}
proxy_pass http://127.0.0.1:8080/api/v1/ts/;
}
}
# server {
# listen 80;
# server_name "ts.moicen.com";
# location / {
# return 301 https://$host$request_uri;
# }
# }
location /api/v2/ts/ {
add_header Access-Control-Allow-Origin $http_origin always;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
add_header Access-Control-Allow-Headers 'Authorization,HtyAdminToken,HtySudoerToken,HtyHost,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always;
add_header Access-Control-Allow-Credentials true always;
add_header Access-Control-Max-Age 86400 always;
if ($request_method = 'OPTIONS') {
return 200;
}
rewrite ^/api/v2/ts/$ /api/v1/ts break;
rewrite ^/api/v2/ts/(.+)$ /api/v1/ts/$1 break;
proxy_pass http://127.0.0.1:3003;
}
}