# 默认服务器配置已移至HTTPS服务器块 # 添加JavaScript MIME类型映射 # types { # application/javascript js mjs ts; # text/javascript js mjs ts; # } server { listen 80; server_name banban.api.talkingq.com; # location = /msUqvicTHS.txt { # root /usr/share/nginx/html; # } # location / { # root /usr/share/nginx/html; # } # HTTP 跳转到 HTTPS location / { return 301 https://$host$request_uri; } # Let's Encrypt HTTP-01 校验 location /.well-known/acme-challenge/ { root /var/www/certbot; } } server { listen 443 ssl; server_name banban.api.talkingq.com; ssl_certificate /etc/letsencrypt/live/banban.api.talkingq.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/banban.api.talkingq.com/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; location = /msUqvicTHS.txt { root /usr/share/nginx/html; } # 将API请求转发到Java后端服务 location / { proxy_pass http://175.24.73.253:80; 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 X-Original-URI $request_uri; proxy_set_header Authorization $http_authorization; add_header Cache-Control "no-store, no-cache, must-revalidate"; expires -1; } # # 将API请求转发到Java后端服务 # location /api/ { # proxy_pass http://server:8091; # 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 X-Original-URI $request_uri; # add_header Cache-Control "no-store, no-cache, must-revalidate"; # expires -1; # } # # 静态资源处理 # location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|mp3|mp4|avi|pdf|txt)$ { # proxy_pass http://node:8084; # 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; # expires 1d; # proxy_buffering off; # add_header Cache-Control "public, max-age=86400"; # } # # Vite特定的虚拟资源处理 # location ~ ^(/@id|/@vite|/node_modules) { # proxy_pass http://node:8084; # 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 Cache-Control "no-store, no-cache, must-revalidate"; # expires -1; # } # # WebSocket支持(Vite HMR) # location / { # proxy_pass http://node:8084; # proxy_set_header Host $host; # proxy_buffering off; # 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-Original-URI $request_uri; # add_header Cache-Control "no-store, no-cache, must-revalidate"; # expires -1; # # WebSocket配置 # proxy_http_version 1.1; # proxy_set_header Upgrade $http_upgrade; # proxy_set_header Connection "upgrade"; # proxy_read_timeout 86400; # } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }