NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
e8c47a0d
V2EX  ›  NGINX

如果 sendfile 找不到文件,可以转到其他地址吗?

  •  
  •   e8c47a0d · Aug 31, 2018 · 2517 views
    This topic created in 2839 days ago, the information mentioned may be changed or developed.

    假设平常使用 < img src="/img/2s7v7cwj7sp_256.jpg" /> 来显示图片,nginx 的配置是:

    location /img/ {
      root /home/xxx/static/;
      sendfile on;
      add_header Cache-Control public;                                       
    }
    

    如果 static 目录中没有 2s7v7cwj7sp_256.jpg 这个文件,有什么方法可以把请求转到例如 /api/get-image/2s7v7cwj7sp_256 这样的地址呢?

    1 replies    2019-01-18 14:22:11 +08:00
    e8c47a0d
        1
    e8c47a0d  
    OP
       Jan 18, 2019
    已经统一改用 node 输出文件了,虽然慢了很多,但减少混乱。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5747 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 03:28 · PVG 11:28 · LAX 20:28 · JFK 23:28
    ♥ Do have faith in what you're doing.