Nginx proxy_pass and URL decryption

Source URL: / api / url% 2Fencoded% 2F /? with = queryParams

Nginx:

location /api { client_max_body_size 2G; proxy_pass https://oursite; } 

With this configuration, I was able to save the URL encoding while going through the proxy. If I add "/" after "our site", it will decrypt the URL.

Problem:

Now the proxy URL still contains "/ api /". I need to remove "/ api /" only when saving parts encoded by URL.

+6
source share
1 answer

Not so long ago there was an unanswered question. In my opinion, you should use api to not have such weird URLs. Another way is to have api on the subdomain. - Alex March 10 11 '15 at 22:58

stackoverflow.com/q/28684300/1016033 - Aleksey March 10 11 '15 at 11:01

One-year call accepted!

  location /api/ { rewrite ^ $request_uri; rewrite ^/api/(.*) $1 break; return 400; proxy_pass http://127.0.0.1:82/$uri; } 

What is it, people!

More details in the Nginx pass_proxy subdirectory without URL decoding , but it even works with the query string:

 % curl "localhost:81/api/url%2Fencoded%2F/?with=queryParams" /url%2Fencoded%2F/?with=queryParams % 
+8
source

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


All Articles