660 lines
26 KiB
Plaintext
660 lines
26 KiB
Plaintext
# ============================================================================
|
||
# 110.42.32.207 Nginx 配置
|
||
# API 服务<E69C8D>?- 处理所有后<E69C89>?API 和代理请<E79086>?
|
||
#
|
||
# 部署步骤<E6ADA5>?
|
||
# 1. 上传到服务器: scp nginx-110.42.32.207.conf ubuntu@110.42.32.207:/tmp/
|
||
# 2. 复制配置: sudo cp /tmp/nginx-110.42.32.207.conf /etc/nginx/sites-available/api.conf
|
||
# 3. 启用配置: sudo ln -s /etc/nginx/sites-available/api.conf /etc/nginx/sites-enabled/
|
||
# 4. 申请证书: sudo certbot --nginx -d api.valuefrontier.cn (或使用其他方<E4BB96>?
|
||
# 5. 测试重载: sudo nginx -t && sudo systemctl reload nginx
|
||
# ============================================================================
|
||
|
||
# WebSocket 连接升级映射
|
||
map $http_upgrade $connection_upgrade {
|
||
default upgrade;
|
||
'' close;
|
||
}
|
||
|
||
# ============================================================================
|
||
# HTTP (端口 80) - 重定向到 HTTPS
|
||
# ============================================================================
|
||
server {
|
||
listen 80;
|
||
server_name api.valuefrontier.cn 110.42.32.207;
|
||
|
||
# Let's Encrypt 验证
|
||
location /.well-known/acme-challenge/ {
|
||
root /var/www/html;
|
||
}
|
||
|
||
location / {
|
||
return 301 https://$host$request_uri;
|
||
}
|
||
}
|
||
|
||
# ============================================================================
|
||
# HTTPS (端口 443) - API 服务
|
||
# ============================================================================
|
||
server {
|
||
listen 443 ssl http2;
|
||
server_name api.valuefrontier.cn 110.42.32.207;
|
||
|
||
# SSL 证书配置
|
||
# 方式1: 使用 IP 证书(需要购买)
|
||
# 方式2: 使用自签名证书(CDN 回源可以配置<E9858D>?HTTP<54>?
|
||
# 方式3: 如果有域名指向这台服务器,用 Let's Encrypt
|
||
#
|
||
# 临时使用自签名证书(生产环境建议使用正式证书<E8AF81>?
|
||
# sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
|
||
# -keyout /etc/nginx/ssl/server.key \
|
||
# -out /etc/nginx/ssl/server.crt \
|
||
# -subj "/CN=110.42.32.207"
|
||
ssl_certificate /etc/nginx/ssl/api.valuefrontier.cn/fullchain.pem;
|
||
ssl_certificate_key /etc/nginx/ssl/api.valuefrontier.cn/privkey.pem;
|
||
|
||
# SSL 优化
|
||
ssl_protocols TLSv1.2 TLSv1.3;
|
||
ssl_prefer_server_ciphers off;
|
||
ssl_session_cache shared:SSL:10m;
|
||
ssl_session_timeout 1d;
|
||
|
||
# 文件上传大小限制(客服图片上传需要)
|
||
client_max_body_size 20M;
|
||
|
||
# ============================================
|
||
# CORS 配置(允<EFBC88>?CDN 域名访问<E8AEBF>?
|
||
# ============================================
|
||
set $cors_origin 'https://valuefrontier.cn';
|
||
|
||
# 如果需要限制来源,取消下面注释
|
||
# set $cors_origin '';
|
||
# if ($http_origin ~* "^https://(www\.)?valuefrontier\.cn$") {
|
||
# set $cors_origin $http_origin;
|
||
# }
|
||
|
||
# ============================================
|
||
# Flask API 代理(本<EFBC88>?gunicorn<72>?
|
||
# ============================================
|
||
location /api/ {
|
||
# 处理 OPTIONS 预检请求
|
||
if ($request_method = 'OPTIONS') {
|
||
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
|
||
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization, X-Requested-With, Cookie' always;
|
||
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||
add_header 'Access-Control-Max-Age' 86400;
|
||
add_header 'Content-Length' 0;
|
||
return 204;
|
||
}
|
||
proxy_hide_header Access-Control-Allow-Origin;
|
||
proxy_hide_header Access-Control-Allow-Credentials;
|
||
proxy_hide_header Access-Control-Allow-Methods;
|
||
proxy_hide_header Access-Control-Allow-Headers;
|
||
proxy_hide_header Access-Control-Expose-Headers;
|
||
|
||
proxy_pass http://127.0.0.1:5001;
|
||
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 "";
|
||
|
||
# 统一添加 CORS <20>?
|
||
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||
|
||
# 超时配置
|
||
proxy_connect_timeout 60s;
|
||
proxy_send_timeout 120s;
|
||
proxy_read_timeout 120s;
|
||
}
|
||
|
||
# ============================================
|
||
# WebSocket - Socket.IO (Flask)
|
||
# ============================================
|
||
location /socket.io/ {
|
||
proxy_pass http://127.0.0.1:5001;
|
||
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_connect_timeout 7d;
|
||
proxy_send_timeout 7d;
|
||
proxy_read_timeout 7d;
|
||
proxy_buffering off;
|
||
}
|
||
|
||
# ============================================
|
||
# 实时行情 WebSocket
|
||
# ============================================
|
||
|
||
# 上交所行情(本地服务)
|
||
location /ws/sse {
|
||
proxy_pass http://127.0.0.1:8765;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Upgrade $http_upgrade;
|
||
proxy_set_header Connection $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_connect_timeout 7d;
|
||
proxy_send_timeout 7d;
|
||
proxy_read_timeout 7d;
|
||
proxy_buffering off;
|
||
}
|
||
|
||
# 深交所行情
|
||
location /ws/szse {
|
||
proxy_pass http://222.128.1.157:8765;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Upgrade $http_upgrade;
|
||
proxy_set_header Connection $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_connect_timeout 7d;
|
||
proxy_send_timeout 7d;
|
||
proxy_read_timeout 7d;
|
||
proxy_buffering off;
|
||
}
|
||
|
||
# ============================================
|
||
# MCP 服务(本地)
|
||
# ============================================
|
||
location /mcp/ {
|
||
proxy_pass http://127.0.0.1:8900/;
|
||
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_buffering off;
|
||
proxy_cache off;
|
||
chunked_transfer_encoding on;
|
||
|
||
proxy_connect_timeout 75s;
|
||
proxy_send_timeout 300s;
|
||
proxy_read_timeout 300s;
|
||
|
||
gzip off;
|
||
add_header X-Accel-Buffering no;
|
||
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always;
|
||
add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, X-Requested-With' always;
|
||
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||
|
||
if ($request_method = 'OPTIONS') {
|
||
return 204;
|
||
}
|
||
}
|
||
|
||
# ============================================
|
||
# 数据服务 API 代理 (222.128.1.157)
|
||
# ============================================
|
||
|
||
# 概念板块 API
|
||
location /concept-api/ {
|
||
# 处理 OPTIONS 预检请求
|
||
if ($request_method = 'OPTIONS') {
|
||
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
|
||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
|
||
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||
add_header 'Access-Control-Max-Age' 86400;
|
||
add_header 'Content-Length' 0;
|
||
return 204;
|
||
}
|
||
|
||
# 隐藏后端返回<E8BF94>?CORS 头(避免重复<E9878D>?
|
||
proxy_hide_header Access-Control-Allow-Origin;
|
||
proxy_hide_header Access-Control-Allow-Credentials;
|
||
proxy_hide_header Access-Control-Allow-Methods;
|
||
proxy_hide_header Access-Control-Allow-Headers;
|
||
proxy_hide_header Access-Control-Expose-Headers;
|
||
|
||
proxy_pass http://222.128.1.157:16801/;
|
||
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;
|
||
|
||
# 统一添加 CORS <20>?
|
||
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||
|
||
proxy_connect_timeout 60s;
|
||
proxy_send_timeout 60s;
|
||
proxy_read_timeout 60s;
|
||
}
|
||
|
||
# Elasticsearch API
|
||
location /es-api/ {
|
||
# 处理 OPTIONS 预检请求
|
||
if ($request_method = 'OPTIONS') {
|
||
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS, HEAD' always;
|
||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
|
||
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||
add_header 'Access-Control-Max-Age' 86400;
|
||
add_header 'Content-Length' 0;
|
||
return 204;
|
||
}
|
||
|
||
# 隐藏后端返回<E8BF94>?CORS 头(避免重复<E9878D>?
|
||
proxy_hide_header Access-Control-Allow-Origin;
|
||
proxy_hide_header Access-Control-Allow-Credentials;
|
||
proxy_hide_header Access-Control-Allow-Methods;
|
||
proxy_hide_header Access-Control-Allow-Headers;
|
||
proxy_hide_header Access-Control-Expose-Headers;
|
||
|
||
proxy_pass http://222.128.1.157:19200/;
|
||
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;
|
||
|
||
# 统一添加 CORS <20>?
|
||
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||
|
||
proxy_connect_timeout 60s;
|
||
proxy_send_timeout 60s;
|
||
proxy_read_timeout 60s;
|
||
proxy_buffering off;
|
||
}
|
||
|
||
# 新闻搜索 API
|
||
location /news-api/ {
|
||
# 处理 OPTIONS 预检请求
|
||
if ($request_method = 'OPTIONS') {
|
||
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
|
||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
|
||
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||
add_header 'Access-Control-Max-Age' 86400;
|
||
add_header 'Content-Length' 0;
|
||
return 204;
|
||
}
|
||
|
||
# 隐藏后端返回<E8BF94>?CORS 头(避免重复<E9878D>?
|
||
proxy_hide_header Access-Control-Allow-Origin;
|
||
proxy_hide_header Access-Control-Allow-Credentials;
|
||
proxy_hide_header Access-Control-Allow-Methods;
|
||
proxy_hide_header Access-Control-Allow-Headers;
|
||
proxy_hide_header Access-Control-Expose-Headers;
|
||
|
||
proxy_pass http://222.128.1.157:21891/;
|
||
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;
|
||
|
||
# 统一添加 CORS <20>?
|
||
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||
|
||
proxy_connect_timeout 90s;
|
||
proxy_send_timeout 90s;
|
||
proxy_read_timeout 90s;
|
||
}
|
||
|
||
# 研报搜索 API
|
||
location /report-api/ {
|
||
# 处理 OPTIONS 预检请求
|
||
if ($request_method = 'OPTIONS') {
|
||
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
|
||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
|
||
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||
add_header 'Access-Control-Max-Age' 86400;
|
||
add_header 'Content-Length' 0;
|
||
return 204;
|
||
}
|
||
|
||
# 隐藏后端返回<E8BF94>?CORS 头(避免重复<E9878D>?
|
||
proxy_hide_header Access-Control-Allow-Origin;
|
||
proxy_hide_header Access-Control-Allow-Credentials;
|
||
proxy_hide_header Access-Control-Allow-Methods;
|
||
proxy_hide_header Access-Control-Allow-Headers;
|
||
proxy_hide_header Access-Control-Expose-Headers;
|
||
|
||
proxy_pass http://222.128.1.157:8811/;
|
||
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;
|
||
|
||
# 统一添加 CORS <20>?
|
||
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||
|
||
proxy_connect_timeout 120s;
|
||
proxy_send_timeout 120s;
|
||
proxy_read_timeout 120s;
|
||
}
|
||
|
||
# 商品分类 API
|
||
location /category-api/ {
|
||
# 处理 OPTIONS 预检请求
|
||
if ($request_method = 'OPTIONS') {
|
||
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
|
||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
|
||
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||
add_header 'Access-Control-Max-Age' 86400;
|
||
add_header 'Content-Length' 0;
|
||
return 204;
|
||
}
|
||
|
||
# 隐藏后端返回<E8BF94>?CORS 头(避免重复<E9878D>?
|
||
proxy_hide_header Access-Control-Allow-Origin;
|
||
proxy_hide_header Access-Control-Allow-Credentials;
|
||
proxy_hide_header Access-Control-Allow-Methods;
|
||
proxy_hide_header Access-Control-Allow-Headers;
|
||
proxy_hide_header Access-Control-Expose-Headers;
|
||
|
||
proxy_pass http://222.128.1.157:18827/;
|
||
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;
|
||
|
||
# 统一添加 CORS <20>?
|
||
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||
|
||
proxy_connect_timeout 120s;
|
||
proxy_send_timeout 120s;
|
||
proxy_read_timeout 120s;
|
||
|
||
proxy_buffering on;
|
||
proxy_buffer_size 128k;
|
||
proxy_buffers 8 256k;
|
||
proxy_busy_buffers_size 512k;
|
||
}
|
||
|
||
# ============================================
|
||
# Bytedesk 客服系统代理 (43.143.189.195)
|
||
# ============================================
|
||
|
||
location /bytedesk/ {
|
||
proxy_pass http://43.143.189.195/;
|
||
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;
|
||
|
||
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always;
|
||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
|
||
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||
|
||
if ($request_method = 'OPTIONS') {
|
||
return 204;
|
||
}
|
||
|
||
proxy_connect_timeout 120s;
|
||
proxy_send_timeout 120s;
|
||
proxy_read_timeout 120s;
|
||
}
|
||
|
||
location /websocket {
|
||
proxy_pass http://43.143.189.195/websocket;
|
||
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_connect_timeout 86400s;
|
||
proxy_send_timeout 86400s;
|
||
proxy_read_timeout 86400s;
|
||
}
|
||
|
||
location /chat/ {
|
||
proxy_pass http://43.143.189.195/chat/;
|
||
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;
|
||
|
||
# 替换响应内容中的 IP 地址
|
||
sub_filter 'http://43.143.189.195' 'https://www.valuefrontier.cn';
|
||
sub_filter_once off;
|
||
sub_filter_types text/css text/javascript application/javascript application/json;
|
||
|
||
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always;
|
||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
|
||
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||
|
||
if ($request_method = 'OPTIONS') {
|
||
return 204;
|
||
}
|
||
|
||
proxy_connect_timeout 120s;
|
||
proxy_send_timeout 120s;
|
||
proxy_read_timeout 120s;
|
||
}
|
||
|
||
location /config/ {
|
||
proxy_pass http://43.143.189.195/config/;
|
||
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;
|
||
|
||
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always;
|
||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
|
||
|
||
if ($request_method = 'OPTIONS') {
|
||
return 204;
|
||
}
|
||
|
||
proxy_connect_timeout 120s;
|
||
proxy_send_timeout 120s;
|
||
proxy_read_timeout 120s;
|
||
}
|
||
|
||
location ^~ /uploads/ {
|
||
proxy_pass http://43.143.189.195/uploads/;
|
||
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;
|
||
|
||
# 隐藏后端返回的 CORS 头(避免重复)
|
||
proxy_hide_header Access-Control-Allow-Origin;
|
||
proxy_hide_header Access-Control-Allow-Credentials;
|
||
proxy_hide_header Access-Control-Allow-Methods;
|
||
proxy_hide_header Access-Control-Allow-Headers;
|
||
|
||
# 统一添加 CORS 头
|
||
add_header 'Access-Control-Allow-Origin' '*' always;
|
||
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
|
||
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept' always;
|
||
|
||
proxy_cache_valid 200 1d;
|
||
expires 1d;
|
||
add_header Cache-Control "public, max-age=86400";
|
||
}
|
||
|
||
location ^~ /file/ {
|
||
proxy_pass http://43.143.189.195/file/;
|
||
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;
|
||
|
||
# 隐藏后端返回的 CORS 头(避免重复)
|
||
proxy_hide_header Access-Control-Allow-Origin;
|
||
proxy_hide_header Access-Control-Allow-Credentials;
|
||
proxy_hide_header Access-Control-Allow-Methods;
|
||
proxy_hide_header Access-Control-Allow-Headers;
|
||
|
||
# CORS 头(解决 ERR_BLOCKED_BY_ORB)
|
||
add_header 'Access-Control-Allow-Origin' '*' always;
|
||
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
|
||
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept' always;
|
||
|
||
proxy_cache_valid 200 1d;
|
||
expires 1d;
|
||
add_header Cache-Control "public, max-age=86400";
|
||
}
|
||
|
||
location /visitor/ {
|
||
proxy_pass http://43.143.189.195/visitor/;
|
||
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 Accept-Encoding "";
|
||
|
||
# 替换 JSON 响应中的 IP 地址
|
||
sub_filter 'http://43.143.189.195' 'https://www.valuefrontier.cn';
|
||
sub_filter_once off;
|
||
sub_filter_types application/json;
|
||
|
||
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always;
|
||
add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, X-Requested-With' always;
|
||
|
||
if ($request_method = 'OPTIONS') {
|
||
return 204;
|
||
}
|
||
|
||
proxy_connect_timeout 120s;
|
||
proxy_send_timeout 120s;
|
||
proxy_read_timeout 120s;
|
||
}
|
||
|
||
location = /stomp {
|
||
# 代理到 bytedesk 的 /websocket 端点
|
||
proxy_pass http://43.143.189.195/websocket;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Upgrade $http_upgrade;
|
||
proxy_set_header Connection $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;
|
||
|
||
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
|
||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
|
||
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||
|
||
if ($request_method = 'OPTIONS') {
|
||
return 204;
|
||
}
|
||
|
||
proxy_connect_timeout 7d;
|
||
proxy_send_timeout 7d;
|
||
proxy_read_timeout 7d;
|
||
proxy_buffering off;
|
||
}
|
||
|
||
location /stomp/ {
|
||
# 代理到 bytedesk 的 /websocket 端点
|
||
proxy_pass http://43.143.189.195/websocket;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Upgrade $http_upgrade;
|
||
proxy_set_header Connection $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;
|
||
|
||
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
|
||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
|
||
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||
|
||
if ($request_method = 'OPTIONS') {
|
||
return 204;
|
||
}
|
||
|
||
proxy_connect_timeout 7d;
|
||
proxy_send_timeout 7d;
|
||
proxy_read_timeout 7d;
|
||
proxy_buffering off;
|
||
}
|
||
|
||
location ^~ /avatars/ {
|
||
proxy_pass http://43.143.189.195/uploads/;
|
||
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;
|
||
|
||
# 隐藏后端返回的 CORS 头(避免重复)
|
||
proxy_hide_header Access-Control-Allow-Origin;
|
||
proxy_hide_header Access-Control-Allow-Credentials;
|
||
proxy_hide_header Access-Control-Allow-Methods;
|
||
proxy_hide_header Access-Control-Allow-Headers;
|
||
|
||
# CORS 头(解决 ERR_BLOCKED_BY_ORB)
|
||
add_header 'Access-Control-Allow-Origin' '*' always;
|
||
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
|
||
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept' always;
|
||
|
||
proxy_cache_valid 200 1d;
|
||
proxy_cache_bypass $http_cache_control;
|
||
}
|
||
|
||
location /assets/ {
|
||
proxy_pass http://43.143.189.195/assets/;
|
||
proxy_set_header Host $host;
|
||
|
||
expires 1d;
|
||
add_header Cache-Control "public, immutable";
|
||
}
|
||
|
||
# ============================================
|
||
# 健康检<E5BAB7>?
|
||
# ============================================
|
||
location /health {
|
||
return 200 'ok';
|
||
add_header Content-Type text/plain;
|
||
}
|
||
|
||
# ============================================
|
||
# 默认返回 404
|
||
# ============================================
|
||
location / {
|
||
return 404 '{"error": "Not Found"}';
|
||
add_header Content-Type application/json;
|
||
}
|
||
}
|