【问题标题】:How do you proxy a specific image with Nginx你如何用 Nginx 代理一个特定的图像
【发布时间】:2019-07-28 15:14:39
【问题描述】:

我有这个网址

https://example.com/image/test.jpg

我想用 Nginx 代理这个 url 上的图像

https://cdn0.tnwcdn.com/wp-content/blogs.dir/1/files/2018/02/google-pacman-796x419.jpg

不改变网址,即与https://example.com/image/test.jpg保持相同

您会在 location 块中放置什么来实现这一点?

【问题讨论】:

  • 你能分享一下你的 nginx 配置吗?

标签: nginx proxy proxypass


【解决方案1】:

您可以在 nginx 配置中使用 proxy_pass 参数:

server {
    # ...
    server_name example.com;
    # ...

    location /image/test.jpg {
        proxy_pass https://cdn0.tnwcdn.com/wp-content/blogs.dir/1/files/2018/02/google-pacman-796x419.jpg;
    }
}

【讨论】:

猜你喜欢
  • 2016-06-04
  • 1970-01-01
  • 2014-06-09
  • 2014-04-04
  • 1970-01-01
  • 2020-07-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多