diff --git a/ngnix.conf b/ngnix.conf index dd41201..9630316 100644 --- a/ngnix.conf +++ b/ngnix.conf @@ -6,11 +6,63 @@ map $http_user_agent $badbot { ~*(GPTBot|ChatGPT-User|Claude-Web|ClaudeBot|Bytespider|CCBot|Google-Extended) 1; } -# 主站 HTTP → HTTPS 重定向 +# 主站 HTTP(SSL 已在外层 nginx 终结,此处只需 serve 内容) server { + root /usr/share/nginx/html; + index index.html; + + client_max_body_size 500M; + listen 80; server_name redpowerfuture.com www.redpowerfuture.com; - return 301 https://$host$request_uri; + + error_page 404 /404.html; + + location = /404.html { + internal; + } + + location = / { + return 302 /web/index.html; + } + + location = /web { + return 302 /web/; + } + + location = /sys { + return 302 /sys/; + } + + location /web/ { + alias /usr/share/nginx/html/web/; + try_files $uri $uri/ /web/index.html; + } + + location /sys/ { + alias /usr/share/nginx/html/; + try_files $uri $uri/ /index.html; + } + + location / { + try_files $uri $uri/ @proxy; + } + + location @proxy { + if ($uri ~ \.[^./]+$) { + return 404; + } + + proxy_pass http://__API_HOST__:8000; + 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_connect_timeout 75s; + proxy_send_timeout 86400s; + proxy_read_timeout 86400s; + } } # Gitea HTTP → HTTPS 重定向