配置文件如下:
server { listen 80; server_name example.com; root /home/foo; location / { proxy_pass http://localhost:8888; } location ~ ^/static/(.*)$ { try_files $document_root/web/static/$1 $document_root/view/dist/$1 $document_root/business/dist/$1 =800; # if (-f $document_root/web/static/$1) { # return 601; # } # if (-f $document_root/view/dist/$1) { # return 602; # } # if (-f $document_root/busines/dist/$1){ # return 603; # } } location @fallback { proxy_pass http://localhost:8888; } }
如果注释 指令 try_files
, 反注释 if
,那么我就会收到 601 , 602 的错误码(说明文件存在) 但是 使用 try_file 就是找不到文件?; 请问各位 V 友,哪里出错了?
在 Google 找了一个下午了,还是没有找到答案。
先谢谢各位,给于帮助了朋友了!
![]() | 1 lhbc 2016-12-28 17:02:31 +08:00 这个配置有点奇葩,看下 error_log 吧 |
![]() | 2 ahu 2016-12-28 20:39:33 +08:00 $1 改为 $uri 看看 |