Translate from NGINX reverse proxy to Kong


#1

Hi people

I have this nginx config and want to translate it to a Kong API:
location = /omni-api/agents {
proxy_pass httx://api.codename.company.com:8083/agents;
proxy_read_timeout 90;
proxy_connect_timeout 90;
proxy_redirect off;
proxy_set_header X-CLIENT_CODE 284;
}
location = /omni-api/dead {
proxy_pass httx://api.codename.company.com:8083/agents/dead;
proxy_read_timeout 90;
proxy_connect_timeout 90;
proxy_redirect off;
proxy_set_header X-CLIENT_CODE 284;
}

Should be: (?)
curl -i -X POST
–url http://localhost:8001/services/
–data ‘name=codename-agents’
–data ‘url=httx://api.codename.company.com:8083/agents’
curl -i -X POST
–url http://localhost:8001/services/
–data ‘name=codename-agents-dead’
–data ‘url=httx://api.codename.company.com:8083/agents/dead’
Then the route:
curl -i -X POST
–url httx://localhost:8001/services/codename-agents/routes
–data ‘hosts[]=codename-agents’
curl -i -X POST
–url httx://localhost:8001/services/codename-agents-dead/routes
–data ‘hosts[]=codename-agents-dead’

It seems a lot of repetition … and how to add a default header to be added? (X-CLIENT_CODE 284)

Thx

Jo


#2

Ok to add the header (X-CLIENT_CODE 284) would be “Request Transformer” plugin.
But how can I not repeat myself from the request above?