简体   繁体   中英

Nginx Location Redirect

If you please, guys, help me with this I want who visit this URL https://123.com/storage/app/profiles/Ar.BB_1585493889.png?w=200&h=200

With the parameters in the end which is w= and h= to do a proxy pass to him only if the URL associated with the two parameters w= and h=. I tried to do this but it doesn't work

> $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;
}

Your help much appreciated.

Working with my colleague he solved the hard part of it and I discovered the solution for proxy passing, it's all about redirect thumbor images to Nginx through a proxy, so the mobile team doesn't have to change any URLS.

        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;

                }
        }

You can still use error_page to redirect people to the real url if the Thumbor server doesn't work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM