0

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.

  • You cannot capture the query string (anything after the `?`) using the `location` directive. You could use `$arg_w` and `$arg_h` instead. – Richard Smith Jul 11 '20 at 10:40
  • Thank you @RichardSmith, I really appreciate your help, can you please help me to pass the three paramaters which is one of them is the filename, I've seen this issue here but couldn't figure out how to apply it to mine. https://stackoverflow.com/questions/8130692/how-can-query-string-parameters-be-forwarded-through-a-proxy-pass-with-nginx – user2698113 Jul 11 '20 at 10:53
  • I want this https://123.com/storage/app/profiles/Ar.BB_1585493889.png?w=200&h=200 to proxy pass to this http:/123.com:8888/unsafe/$2x$3/smart/https://123.com/storage/app/profiles/$1 – user2698113 Jul 11 '20 at 10:54

1 Answers1

0

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.