使用nginx代理外部图像



有没有一种方法可以在不下载并存储在本地的情况下用nginx代理外部图像?即,将图像的URI传递给我的代理服务器,如下所示:

`http://myproxydomain.com/http://example.com/image.jpg`

并将此URI包含在我的站点上的图像的src属性中。

是——这是可能的:

    merge_slashes off;
    location ~ /(?<r>http://.*) {
        resolver 127.0.0.1;
        proxy_pass $r;
    }

你是否应该这样做是另一回事。拥有merge_slashes off可能不是一个好主意。

最新更新