Get nginx arguments and path for proxy_pass

I have this url:

http://localhost:8888/images/upload/root/folderA/folderB?arg1=A&arg2=B

so I want to redirect everything to:

http://localhost:8080/v1/files_upload/

and it should be something like:

http://localhost:8080/v1/files_upload/root/folderA/folderB?arg1=A&arg2=B

I have the following:

location ~ ^/images/upload/([^/]+)(/.*)\?(.*)$ {

     upload_pass @after_upload;
     ...
     ...

}
location @after_upload {
            proxy_pass   http://localhost:8080/v1/files_put/$1/$2?$3;
    }

I checked it and only $ 1 and $ 2 work , but $ 3 arguments are not sent to proxy_pass

Thanks in advance!

0
source share
1 answer

The directive locationdoes not match the request arguments; it only checks the request path. You should use a variable $args(or more specific $arg_arg1and $arg_arg2):

location @after_upload {
    proxy_pass   http://localhost:8080/v1/files_put/$1/$2?$args;
}
0
source

Source: https://habr.com/ru/post/1611275/


All Articles