69 lines
2.1 KiB
Plaintext
69 lines
2.1 KiB
Plaintext
|
|
# AI Service Nginx Configuration
|
||
|
|
# 将此文件放置于 /etc/nginx/conf.d/ai-service.conf
|
||
|
|
# 或 include 到主配置文件中
|
||
|
|
|
||
|
|
upstream ai_service_admin {
|
||
|
|
server 127.0.0.1:8181;
|
||
|
|
}
|
||
|
|
|
||
|
|
server {
|
||
|
|
listen 80;
|
||
|
|
server_name your-domain.com; # 替换为你的域名或服务器IP
|
||
|
|
|
||
|
|
# 访问日志
|
||
|
|
access_log /var/log/nginx/ai-service.access.log;
|
||
|
|
error_log /var/log/nginx/ai-service.error.log;
|
||
|
|
|
||
|
|
location / {
|
||
|
|
proxy_pass http://ai_service_admin;
|
||
|
|
proxy_http_version 1.1;
|
||
|
|
proxy_set_header Upgrade $http_upgrade;
|
||
|
|
proxy_set_header Connection 'upgrade';
|
||
|
|
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_cache_bypass $http_upgrade;
|
||
|
|
|
||
|
|
# SSE 流式响应支持
|
||
|
|
proxy_read_timeout 300s;
|
||
|
|
proxy_connect_timeout 75s;
|
||
|
|
proxy_buffering off;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
# HTTPS 配置示例 (使用 Let's Encrypt)
|
||
|
|
# server {
|
||
|
|
# listen 443 ssl http2;
|
||
|
|
# server_name your-domain.com;
|
||
|
|
#
|
||
|
|
# ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
|
||
|
|
# ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;
|
||
|
|
#
|
||
|
|
# ssl_protocols TLSv1.2 TLSv1.3;
|
||
|
|
# ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
|
||
|
|
# ssl_prefer_server_ciphers off;
|
||
|
|
#
|
||
|
|
# location / {
|
||
|
|
# proxy_pass http://ai_service_admin;
|
||
|
|
# proxy_http_version 1.1;
|
||
|
|
# proxy_set_header Upgrade $http_upgrade;
|
||
|
|
# proxy_set_header Connection 'upgrade';
|
||
|
|
# 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_cache_bypass $http_upgrade;
|
||
|
|
# proxy_read_timeout 300s;
|
||
|
|
# proxy_connect_timeout 75s;
|
||
|
|
# proxy_buffering off;
|
||
|
|
# }
|
||
|
|
# }
|
||
|
|
|
||
|
|
# HTTP 重定向到 HTTPS
|
||
|
|
# server {
|
||
|
|
# listen 80;
|
||
|
|
# server_name your-domain.com;
|
||
|
|
# return 301 https://$server_name$request_uri;
|
||
|
|
# }
|