0

I'm trying to match a location that looks like this /v1/images/{path1}/fetch?imageUrl={imageUrl}, but I get this error in the terminal [error] 7#7: *1 open() "/usr/local/openresty/nginx/html/v1/images/raw/fetch" whenever I try to make an example request for the variables in the GET route.

map $arg_imageUrl $image_ext {
  default "";
  ~*\.([a-zA-Z]+)$ $1;
}

server {
  listen 80;

location "/v1/images/{path1}/fetch?imageUrl={imageUrl}" {
    if ($args ~* "imageUrl=.*") {
      set_sha1 $variable $arg_imageUrl;
      set $path1 $arg_path1;
      set $imageUrl "https://testing-url/test-properties/images/$variable/$path1.$image_ext";
      add_header Content-Type text/plain;
      return 200 $imageUrl;
      # proxy_pass $imageUrl;
      # access_log ./log_file.log combined;
    }
  }
}
Esam Olwan
  • 320
  • 1
  • 5
  • 16
  • `location` is tested against that part of the URL before the `?`. By the time `location` blocks are searched for a match, the query string has been stripped off and placed into the `$arg_` variables. See [`location` directive documentation](http://nginx.org/en/docs/http/ngx_http_core_module.html#location) and [how Nginx processes a request](http://nginx.org/en/docs/http/request_processing.html). – Richard Smith Mar 25 '23 at 09:00

0 Answers0