-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnginx.conf
More file actions
49 lines (42 loc) · 1.7 KB
/
Copy pathnginx.conf
File metadata and controls
49 lines (42 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
server {
listen 80;
proxy_set_header Host $host;
# 1. 定义全局根目录 (确保 index.html 在这个目录下)
root /usr/share/nginx/html;
index index.html index.htm;
# Same-origin deployment: change this address to the actual Go API address.
# In Docker, 127.0.0.1 means this container; use the API container/service address.
location ~ ^/(site/api/|cloudflare/) {
client_max_body_size 8k;
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_read_timeout 15s;
proxy_connect_timeout 3s;
proxy_next_upstream off;
}
# 2. 将原来的 location /costrict/ 改为 location /
# 这样 /home, /login 等所有路由都会进入这里
location / {
# 3. 这里不需要 alias 了,直接用上面的全局 root 即可
# 4. 核心修复:找不到文件时,回退到 /index.html
try_files $uri $uri/ /index.html;
}
# 如果你确实需要保留 /costrict/ 这个特定前缀的访问逻辑,
# 可以保留原有的 block,但必须加上上面的 location / 来处理普通页面路由。
# --- 以下保持不变 ---
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
server_tokens off;
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
}