Get arguments Nginx and path for proxy_pass

天大地大妈咪最大 提交于 2019-12-11 19:47:56

问题


I have this URL:

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

so, I want redirect all to:

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

and it must 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 works $1 and $2, but the arguments $3 are not sent to proxy_pass

Thanks in advance!


回答1:


The location directive doesn't match request arguments, it only checks request path. You should use the $args variable (or more specific $arg_arg1 and $arg_arg2):

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


来源:https://stackoverflow.com/questions/22945208/get-arguments-nginx-and-path-for-proxy-pass

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!