Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx proxy_pass having problems with querystring for an API

Tags:

nginx

api

I'm trying to proxy a certain rest endpoint on my linux api box to my windows box. Here's what I have right now.

My linux api box

...
location ~ ^/api/v0/roslyn(.*)$ {
    resolver 8.8.8.8;
    proxy_pass $scheme://my-windows-box.com/roslyn$1;
}

For example, I'd like to proxy the following url

http://my-linux-box.com/api/v0/roslyn?q=5

to

http://my-windows-box.com/roslyn?q=5

However, it seems to be missing the querystring, so the regex is failing?

like image 310
Brandon Browning Avatar asked Mar 23 '23 08:03

Brandon Browning


1 Answers

I don't think you can match the args by regex, try this instead

location /api/v0/roslyn {
    resolver 8.8.8.8;
    proxy_pass $scheme://my-windows-box.com/roslyn$is_args$query_string;
}
like image 191
Mohammad AbuShady Avatar answered Apr 06 '23 11:04

Mohammad AbuShady