43 lines
1.4 KiB
Plaintext
43 lines
1.4 KiB
Plaintext
# ============================================
|
|
# 小程序后台 - API 服务
|
|
# 接入现有后端 quanyixiaozhushou-app (宿主机3000端口)
|
|
# 由主 Nginx 反向代理,此文件可独立维护
|
|
# ============================================
|
|
|
|
server {
|
|
listen 80;
|
|
server_name api-miniapp.dxz99wyr.cn;
|
|
|
|
# 日志
|
|
access_log /var/log/nginx/miniapp-api.access.log main;
|
|
error_log /var/log/nginx/miniapp-api.error.log warn;
|
|
|
|
location / {
|
|
# 反向代理到宿主机的3000端口(quanyixiaozhushou-app后端)
|
|
proxy_pass http://host.docker.internal:3000;
|
|
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;
|
|
|
|
# WebSocket 支持
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
proxy_connect_timeout 60s;
|
|
proxy_send_timeout 60s;
|
|
proxy_read_timeout 60s;
|
|
|
|
# CORS 头部
|
|
add_header Access-Control-Allow-Origin * always;
|
|
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" 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;
|
|
}
|
|
}
|
|
}
|