mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 23:23:55 +08:00
feat: add FastAPI manager API compatibility baseline
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
UPSTREAM=${MANAGER_API_UPSTREAM:-manager-api-fastapi:8002}
|
||||
case "${UPSTREAM}" in
|
||||
''|*[!A-Za-z0-9._:-]*)
|
||||
echo "MANAGER_API_UPSTREAM must be a hostname-or-IP and port" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
export MANAGER_API_UPSTREAM=${UPSTREAM}
|
||||
envsubst '${MANAGER_API_UPSTREAM}' \
|
||||
< /etc/nginx/nginx.conf.template \
|
||||
> /tmp/manager-api-nginx.conf
|
||||
exec nginx -c /tmp/manager-api-nginx.conf -g 'daemon off;'
|
||||
@@ -0,0 +1,45 @@
|
||||
worker_processes auto;
|
||||
pid /tmp/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
access_log /dev/stdout;
|
||||
error_log /dev/stderr warn;
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
client_max_body_size 100m;
|
||||
|
||||
upstream manager_api_fastapi {
|
||||
server ${MANAGER_API_UPSTREAM};
|
||||
keepalive 32;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8002;
|
||||
server_name _;
|
||||
|
||||
location = /xiaozhi {
|
||||
return 308 /xiaozhi/;
|
||||
}
|
||||
|
||||
location /xiaozhi/ {
|
||||
proxy_pass http://manager_api_fastapi;
|
||||
proxy_http_version 1.1;
|
||||
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;
|
||||
proxy_set_header Connection "";
|
||||
proxy_connect_timeout 10s;
|
||||
proxy_send_timeout 130s;
|
||||
proxy_read_timeout 130s;
|
||||
proxy_request_buffering off;
|
||||
proxy_buffering off;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user