| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- server {
- listen 8011;
- # Web 前端域名
- server_name 121.43.228.102;
- # HTTPS 配置(取消注释并配置 SSL 证书后启用)
- # listen 443 ssl http2;
- # ssl_certificate /path/to/ssl/cert.pem;
- # ssl_certificate_key /path/to/ssl/key.pem;
- # ssl_protocols TLSv1.2 TLSv1.3;
- # ssl_ciphers HIGH:!aNULL:!MD5;
- # ssl_prefer_server_ciphers on;
- # 日志配置
- access_log /var/log/nginx/dibang-web-access.log;
- error_log /var/log/nginx/dibang-web-error.log;
- # Web 前端根目录
- root /iflytek/dibang/web;
- index index.html;
- # 字符集
- charset utf-8;
- # 前端静态文件 - SPA 路由支持
- location / {
- try_files $uri $uri/ /index.html;
- add_header Cache-Control "no-cache, no-store, must-revalidate";
- add_header Pragma "no-cache";
- add_header Expires "0";
- }
- # 静态资源缓存(JS、CSS、图片等)
- location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|webp)$ {
- expires 1y;
- add_header Cache-Control "public, immutable";
- access_log off;
- }
- # API 代理到后端服务
- location /api {
- proxy_pass http://127.0.0.1:8000;
- proxy_http_version 1.1;
-
- # WebSocket 支持
- proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection "upgrade";
-
- # 请求头(包含端口信息,确保前端能获取到正确的端口)
- proxy_set_header Host $host:$server_port;
- 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 X-Forwarded-Host $host;
- proxy_set_header X-Forwarded-Port $server_port;
-
- # 超时设置
- proxy_connect_timeout 60s;
- proxy_send_timeout 60s;
- proxy_read_timeout 60s;
-
- # 缓冲设置(关闭缓冲以支持流式响应)
- proxy_buffering off;
- proxy_request_buffering off;
-
- # 错误处理
- proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
- }
- # 健康检查端点
- location /health {
- proxy_pass http://127.0.0.1:8000/;
- proxy_set_header Host $host:$server_port;
- access_log off;
- }
- # 禁止访问隐藏文件
- location ~ /\. {
- deny all;
- access_log off;
- log_not_found off;
- }
- }
- # ============================================
- # H5 移动端配置(域名访问)
- # ============================================
- server {
- listen 8012;
- # H5 移动端域名和 IP(IP 直接访问时显示 H5)
- server_name 121.43.228.102;
- # HTTPS 配置(取消注释并配置 SSL 证书后启用)
- # listen 443 ssl http2;
- # ssl_certificate /path/to/ssl/cert.pem;
- # ssl_certificate_key /path/to/ssl/key.pem;
- # ssl_protocols TLSv1.2 TLSv1.3;
- # ssl_ciphers HIGH:!aNULL:!MD5;
- # ssl_prefer_server_ciphers on;
- # 日志配置
- access_log /var/log/nginx/dibang-h5-access.log;
- error_log /var/log/nginx/dibang-h5-error.log;
- # H5 前端根目录
- root /iflytek/dibang/app;
- index index.html;
- # 字符集
- charset utf-8;
- # 前端静态文件 - SPA 路由支持
- location / {
- try_files $uri $uri/ /index.html;
- add_header Cache-Control "no-cache, no-store, must-revalidate";
- add_header Pragma "no-cache";
- add_header Expires "0";
- }
- # 静态资源缓存(JS、CSS、图片等)
- location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|webp)$ {
- expires 1y;
- add_header Cache-Control "public, immutable";
- access_log off;
- }
- # API 代理到后端服务
- location /api {
- proxy_pass http://127.0.0.1:8000;
- proxy_http_version 1.1;
-
- # WebSocket 支持
- proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection "upgrade";
-
- # 请求头(包含端口信息,确保前端能获取到正确的端口)
- proxy_set_header Host $host:$server_port;
- 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 X-Forwarded-Host $host;
- proxy_set_header X-Forwarded-Port $server_port;
-
- # 超时设置
- proxy_connect_timeout 60s;
- proxy_send_timeout 60s;
- proxy_read_timeout 60s;
-
- # 缓冲设置(关闭缓冲以支持流式响应)
- proxy_buffering off;
- proxy_request_buffering off;
-
- # 错误处理
- proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
- }
- # 健康检查端点
- location /health {
- proxy_pass http://127.0.0.1:8000/;
- proxy_set_header Host $host:$server_port;
- access_log off;
- }
- # 禁止访问隐藏文件
- location ~ /\. {
- deny all;
- access_log off;
- log_not_found off;
- }
- }
|