Kong service and routes with Injected NGINX_INCLUDE locations

Hi there, I am having some trouble getting Kong to proxy a request to a route which I believe I have defined a location block in Kongs custom include.

During Kong startup I use the KONG_NGINX_INCLUDE directive to load a custom NGINX file. I have some lua code which has to be run during the request to transform JSON to protobuf.

lua_code_cache off;

server {
  listen 9000;
  server_name localhost;

   location /v1/Create {
   access_by_lua_block { SOME_CODE}
   body_filter_by_lua_block {SOME_CODE}
   grpc_set_header Content-Type application/grpc;
    grpc_pass  app:50051;
   } 
}

I have set up my service like so.

curl -i -X POST \
--url http://localhost:8001/services/ \
--data 'name=apitest' \
--data 'url=http://localhost:9000'

And added a route

curl -i -X POST --url http://localhost:8001/services/apitest/routes --data 'paths[]=/v1/Create' 

Shouldn’t I be able to now call the following url with whatever data i normally do?

curl http://localhost:8000/v1/Create

Instead the output i get back is

kong_1  | <> *41963 "/usr/local/kong/html/index.html" is not found (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "POST / HTTP/1.1", host: "localhost:9000"
kong_1  | <> "POST /v1/Create HTTP/1.1" 404 118 "-" "curl/7.65.3"

Why is it trying to retrieve the index.html file? Shouldn’t it route the request to http:localhost:9000/v1/Create?
In other words why is it not executing the lua code defined in the location block of the custom nginx server block that was injected into Kong.


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ