I’m using NGINX as reverse proxy, with dynamic mapping to forward the request to the correct backend.
Here is my map directive
<code>map $arg_action $backend {
"~^nginx/.*" nginx-web;
"~^httpd/.*" httpd-web;
}
</code>
<code>map $arg_action $backend {
"~^nginx/.*" nginx-web;
"~^httpd/.*" httpd-web;
}
</code>
map $arg_action $backend {
"~^nginx/.*" nginx-web;
"~^httpd/.*" httpd-web;
}
I’m proxying the traffic to the correct upstream by the following:
<code>location /data {
proxy_redirect off;
proxy_bypass http://$backend/$arg_action;
}
</code>
<code>location /data {
proxy_redirect off;
proxy_bypass http://$backend/$arg_action;
}
</code>
location /data {
proxy_redirect off;
proxy_bypass http://$backend/$arg_action;
}
The APIs I’m triggering are:
<code> /data?action=httpd/v1/CompareAnimals?animal=cat&bird=high
</code>
<code> /data?action=httpd/v1/CompareAnimals?animal=cat&bird=high
</code>
/data?action=httpd/v1/CompareAnimals?animal=cat&bird=high
The httpd service gets the following API:
<code>httpd/v1/CompareAnimals?animal=cat, NGINX will not bypass anything after "&" character
</code>
<code>httpd/v1/CompareAnimals?animal=cat, NGINX will not bypass anything after "&" character
</code>
httpd/v1/CompareAnimals?animal=cat, NGINX will not bypass anything after "&" character
How can I make the httpd service to get the full API when I trigger it? such as :
<code>httpd/v1/CompareAnimals?animal=cat&bird=high
</code>
<code>httpd/v1/CompareAnimals?animal=cat&bird=high
</code>
httpd/v1/CompareAnimals?animal=cat&bird=high
and not only
<code>httpd/v1/CompareAnimals?animal=cat
</code>
<code>httpd/v1/CompareAnimals?animal=cat
</code>
httpd/v1/CompareAnimals?animal=cat
Seems like you should use proxy_pass
over proxy_bypass
, and just add $args
and $is_args
variable provided by NGINX
<code>location /data {
proxy_redirect off;
proxy_pass http://$backend/$arg_action$is_args$args;
}
</code>
<code>location /data {
proxy_redirect off;
proxy_pass http://$backend/$arg_action$is_args$args;
}
</code>
location /data {
proxy_redirect off;
proxy_pass http://$backend/$arg_action$is_args$args;
}