【问题标题】:Nginx Location RedirectNginx 位置重定向
【发布时间】:2020-07-13 13:26:23
【问题描述】:

如果你愿意,伙计们,帮我解决这个问题 我想要访问这个 URL 的人 https://123.com/storage/app/profiles/Ar.BB_1585493889.png?w=200&h=200

最后的参数是w=和h= 只有当 URL 与两个参数 w= 和 h= 相关联时,才能将代理传递给他。 我试图这样做,但它不起作用

> $1 = for the file name which is Ar.BB_1585493889.png
> $2 = for width(w=) 
> $3 = for height (h=)


location ~* ^/storage/app/profiles/(.*)?w\=(.*)\&h\=(.*) {
proxy_pass http:/123.com:8888/unsafe/$2x$3/smart/https://123.com/storage/app/profiles/$1;
}

非常感谢您的帮助。

【问题讨论】:

标签: nginx nginx-reverse-proxy nginx-location


【解决方案1】:

与我的同事合作,他解决了其中的难题,我发现了代理传递的解决方案,这完全是关于通过代理将拇指图像重定向到 Nginx,因此移动团队不必更改任何 URL。

        location ~* ^/storage/app/profiles/(.*) {
#error_page   400 401 402 403 404 405 500 501 502 503 504  @error_page;
                set $image $1;
                if ($is_args = "?") {
                        rewrite ^.*$ "/unsafe/${arg_w}x${arg_h}/smart/https://123.com/storage/app/profiles/$image?" break;
                        proxy_pass http://127.0.0.1:8888;

                }
        }

如果 Thumbor 服务器不工作,您仍然可以使用 error_page 将人们重定向到真实 url。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-16
    相关资源
    最近更新 更多