128 lines
4.0 KiB
Plaintext
128 lines
4.0 KiB
Plaintext
|
|
upstream cc_ai_kefu {
|
||
|
|
server 127.0.0.1:8016;
|
||
|
|
keepalive 64;
|
||
|
|
}
|
||
|
|
|
||
|
|
server {
|
||
|
|
listen 80;
|
||
|
|
server_name _; # 替换为你的域名,如 chat.xxx.com
|
||
|
|
|
||
|
|
# 强制跳转 HTTPS(取消注释启用)
|
||
|
|
# return 301 https://$host$request_uri;
|
||
|
|
|
||
|
|
location / {
|
||
|
|
proxy_pass http://cc_ai_kefu;
|
||
|
|
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;
|
||
|
|
}
|
||
|
|
|
||
|
|
# WebSocket 专用路由
|
||
|
|
location /ws/ {
|
||
|
|
proxy_pass http://cc_ai_kefu;
|
||
|
|
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_read_timeout 3600s;
|
||
|
|
proxy_send_timeout 3600s;
|
||
|
|
}
|
||
|
|
|
||
|
|
# 静态文件直接由 OpenResty 处理,不走后端
|
||
|
|
location /static/ {
|
||
|
|
alias /www/cc_ai_kefu/static/;
|
||
|
|
expires 7d;
|
||
|
|
add_header Cache-Control "public, immutable";
|
||
|
|
add_header Access-Control-Allow-Origin *;
|
||
|
|
add_header Access-Control-Allow-Methods "GET, OPTIONS";
|
||
|
|
}
|
||
|
|
|
||
|
|
# Widget.js 允许跨域(供其他网站嵌入)
|
||
|
|
location = /static/widget.js {
|
||
|
|
alias /www/cc_ai_kefu/static/widget.js;
|
||
|
|
expires 1d;
|
||
|
|
add_header Cache-Control "public";
|
||
|
|
add_header Access-Control-Allow-Origin *;
|
||
|
|
add_header Access-Control-Allow-Methods "GET, OPTIONS";
|
||
|
|
add_header Access-Control-Allow-Headers "Origin, Content-Type, Accept";
|
||
|
|
}
|
||
|
|
|
||
|
|
# API 接口
|
||
|
|
location /api/ {
|
||
|
|
proxy_pass http://cc_ai_kefu;
|
||
|
|
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;
|
||
|
|
}
|
||
|
|
|
||
|
|
# Health check
|
||
|
|
location /health {
|
||
|
|
proxy_pass http://cc_ai_kefu;
|
||
|
|
}
|
||
|
|
|
||
|
|
access_log /var/log/nginx/cc_ai_kefu_access.log;
|
||
|
|
error_log /var/log/nginx/cc_ai_kefu_error.log;
|
||
|
|
}
|
||
|
|
|
||
|
|
# HTTPS 配置(取消注释并填入证书路径启用)
|
||
|
|
# server {
|
||
|
|
# listen 443 ssl http2;
|
||
|
|
# server_name _; # 替换为你的域名
|
||
|
|
#
|
||
|
|
# ssl_certificate /etc/nginx/ssl/cert.pem;
|
||
|
|
# ssl_certificate_key /etc/nginx/ssl/key.pem;
|
||
|
|
# ssl_protocols TLSv1.2 TLSv1.3;
|
||
|
|
# ssl_ciphers HIGH:!aNULL:!MD5;
|
||
|
|
#
|
||
|
|
# location / {
|
||
|
|
# proxy_pass http://cc_ai_kefu;
|
||
|
|
# 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 /ws/ {
|
||
|
|
# proxy_pass http://cc_ai_kefu;
|
||
|
|
# 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_read_timeout 3600s;
|
||
|
|
# proxy_send_timeout 3600s;
|
||
|
|
# }
|
||
|
|
#
|
||
|
|
# location /static/ {
|
||
|
|
# alias /www/cc_ai_kefu/static/;
|
||
|
|
# expires 7d;
|
||
|
|
# add_header Cache-Control "public, immutable";
|
||
|
|
# add_header Access-Control-Allow-Origin *;
|
||
|
|
# }
|
||
|
|
#
|
||
|
|
# location = /static/widget.js {
|
||
|
|
# alias /www/cc_ai_kefu/static/widget.js;
|
||
|
|
# expires 1d;
|
||
|
|
# add_header Cache-Control "public";
|
||
|
|
# add_header Access-Control-Allow-Origin *;
|
||
|
|
# }
|
||
|
|
#
|
||
|
|
# location /api/ {
|
||
|
|
# proxy_pass http://cc_ai_kefu;
|
||
|
|
# 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;
|
||
|
|
# }
|
||
|
|
#
|
||
|
|
# access_log /var/log/nginx/cc_ai_kefu_access.log;
|
||
|
|
# error_log /var/log/nginx/cc_ai_kefu_error.log;
|
||
|
|
# }
|