代码拉取完成,页面将自动刷新
server {
listen 80;
# 这里配置服务器的域名
#server_name api.aidea.com;
gzip on;
gzip_static on;
gzip_vary on;
gzip_types text/plain application/x-javascript text/css application/xml text/xml application/javascript;
# 这里配置 SSL 证书路径
#ssl_certificate /etc/nginx/certs.d/api.aidea.com.pem;
#ssl_certificate_key /etc/nginx/certs.d/api.aidea.com.key;
# 将用户端的真实 IP 传递给后端服务
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;
# 支持跨域(Web 端专用)
add_header Access-Control-Allow-Origin * always;
add_header Access-Control-Allow-Methods GET,OPTIONS,POST,PUT,DELETE always;
add_header Access-Control-Allow-Headers x-platform-version always;
add_header Access-Control-Allow-Headers x-client-version always;
add_header Access-Control-Allow-Headers x-platform always;
add_header Access-Control-Allow-Headers x-language always;
add_header Access-Control-Allow-Headers authorization always;
add_header Access-Control-Allow-Headers content-type always;
add_header Access-Control-Allow-Headers openai-organization always;
# 默认禁止直接访问 API 根地址
location / {
rewrite ^/(.*) http://127.0.0.1 redirect;
}
# 如果你在同一台服务器上部署了 AIdea 前端项目,这里指定前端项目的路径
# 注意不要忘记注释掉上面的默认禁止直接访问 API 根地址的配置
# location / {
# root /data/app;
# index index.html;
# try_files $uri $uri/ =404;
# }
# OpenAI Chat Stream 协议支持(服务端推送)
location /v1/chat/completions {
proxy_pass http://ai_api_backend;
proxy_set_header Upgrade $http_upgrade;
proxy_http_version 1.1;
proxy_set_header Connection 'upgrade';
chunked_transfer_encoding off;
proxy_cache off;
proxy_buffering off;
proxy_read_timeout 300s;
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;
}
# 公开 API v1
location /v1/ {
proxy_pass http://ai_api_backend;
}
# 公开 API v2
location /v2/ {
proxy_pass http://ai_api_backend;
}
# 公开 API
location /public/ {
proxy_pass http://ai_api_backend;
}
# Universal Link
location /.well-known/apple-app-site-association {
proxy_pass http://ai_api_backend;
}
}
upstream ai_api_backend {
# 后端服务地址
server 192.168.0.109:8080;
keepalive 32;
}
# 所有 HTTP 请求重定向到 HTTPS
#server {
# listen 80;
# # 这里配置服务器的域名
# server_name api.aidea.com;
#
# rewrite ^(.*) https://api.aidea.com$1 permanent;
#}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。