Skip to content

help request: How to use proxy-pass plugin with regex_uri attributes when the url is encoded #9638

Description

@yujinchoi-94

Description

Hi, I have to call an upstream server with encoded string.

For example,
I want to make a request like this.

curl -X GET "{apisix-server-address}/rest/alimi/alimianswer/1234/N/%ED%85%8C%EC%8A%A4%ED%8A%B8"

(%ED%85%8C%EC%8A%A4%ED%8A%B8 is encoded string)

I've found out that the apisix uses decoded URI coming from nginx through this
So, i've tried using use_real_request_uri_unsafe option, but it doesn't work with regex_uri.

Is there any way to call the upstream server with encoded string?


Here's my configuration.

- name: proxy-rewrite
  enable: true
	config:
		regex_uri:
			- /rest/alimi/alimianswer/(.+)/(.+)/(.+)
			- /cv/v1/emergency/answer?emerNtceSeq=$1&confirmYn=$2&answerCtnt=$3
    use_real_request_uri_unsafe: true

When I used the above configuration, the log result were like this

10.205.164.68 - - [12/Jun/2023:04:42:21 +0000] .... "GET /rest/alimi/alimianswer/1234/N/%ED%85%8C%EC%8A%A4%ED%8A%B8 HTTP/1.1" 400 808 0.077 "-" "curl/7.79.1" - - - "http://{upstream-server}"

What I want is to call the upstream server with below url

http://{upstream-server}/cv/v1/emergency/answer?emerNtceSeq=1234&confirmYn=N&answerCtnt=%ED%85%8C%EC%8A%A4%ED%8A%B8

Environment

  • APISIX version (run apisix version):
    • /usr/local/openresty//luajit/bin/luajit /usr/local/apisix/apisix/cli/apisix.lua version 3.2.0
  • Operating system (run uname -a):
    • Linux dev-apisix-6d55c4cfd5-nqw9x 5.4.226-129.415.amzn2.x86_64 #1 SMP Fri Dec 9 12:54:21 UTC 2022 x86_64 GNU/Linux
  • OpenResty / Nginx version (run openresty -V or nginx -V):
    • openresty -V nginx version: openresty/1.21.4.1
    • nginx -V nginx version: openresty/1.21.4.1
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status
✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions