# Init\_by\_lua\_block configuration in KONG\_NGINX\_HTTP\_INCLUDE causes start up errors

**URL:** https://discuss.konghq.com/t/init-by-lua-block-configuration-in-kong-nginx-http-include-causes-start-up-errors/4264
**Category:** Questions
**Created:** [August 20, 2019, 8:05am UTC](https://discuss.konghq.com/t/init-by-lua-block-configuration-in-kong-nginx-http-include-causes-start-up-errors/4264 "2019-08-20T08:05:09Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Sevren](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@Sevren](https://discuss.konghq.com/u/Sevren)
#### Post date: [August 20, 2019, 8:05am UTC](https://discuss.konghq.com/t/init-by-lua-block-configuration-in-kong-nginx-http-include-causes-start-up-errors/4264/1 "2019-08-20T08:05:09Z")

</div>

Hi, I have some code that I would like to run during the configuration loading phase of Kong. To setup variables and stuff that I need.

In Openresty this configuration sample gets loaded without an issue, In Kong however the init\_by\_lua\_block in my extra configuration causes start up issues of the Kong service.

It seems like both the default Kong configuration has its own `init_by_lua_block` and my extra configuration has one as well confusing Kong? How can get my extra `init_by_lua_block` to exist side by side with the default Kong configuration?

Note: I am using Kong version 1.3.0rc1-alpine docker image because I want to use the grpc directives from Openresty.

```auto
2019/08/20 07:59:27 [verbose] Kong: 1.3.0rc1
kong_1 | Error: 
kong_1 | /usr/local/share/lua/5.1/kong/cmd/prepare.lua:12: could not prepare Kong prefix at /usr/local/kong: nginx configuration is invalid (exit code 1):
kong_1 | nginx: [alert] lua_code_cache is off; this will hurt performance in /configs/grpc.kong.conf:1
kong_1 | nginx: [emerg] is duplicate in /usr/local/kong/nginx-kong.conf:35
kong_1 | nginx: configuration file /usr/local/kong/nginx.conf test failed
kong_1 | 
kong_1 | stack traceback:
kong_1 | [C]: in function 'error'
kong_1 | /usr/local/share/lua/5.1/kong/cmd/prepare.lua:12: in function 'cmd_exec'
kong_1 | /usr/local/share/lua/5.1/kong/cmd/init.lua:87: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:87>
kong_1 | [C]: in function 'xpcall'
kong_1 | /usr/local/share/lua/5.1/kong/cmd/init.lua:87: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:44>
kong_1 | /usr/local/bin/kong:9: in function 'file_gen'
kong_1 | init_worker_by_lua:49: in function <init_worker_by_lua:47>
kong_1 | [C]: in function 'xpcall'
kong_1 | init_worker_by_lua:56: in function <init_worker_by_lua:54>
kong_1 | 2019/08/20 07:59:27 [verbose] no config file found at /etc/kong/kong.conf
kong_1 | 2019/08/20 07:59:27 [verbose] no config file found at /etc/kong.conf
kong_1 | 2019/08/20 07:59:27 [verbose] no config file, skip loading
kong_1 | 2019/08/20 07:59:27 [verbose] prefix in use: /usr/local/kong
kong_1 | 2019/08/20 07:59:27 [verbose] preparing nginx prefix directory at /usr/local/kong
kong_1 | 2019/08/20 07:59:27 [verbose] SSL enabled, no custom certificate set: using default certificate
kong_1 | 2019/08/20 07:59:27 [verbose] default SSL certificate found at /usr/local/kong/ssl/kong-default.crt

```

Sample extra configuration file to be loaded when Kong starts

```auto
lua_code_cache off;

init_by_lua_block {
  -- Define global import paths
  PROTOC_IMPORT_PATHS = {
    "/usr/local/protoc/include"
  }
}

server {
  listen 8000;
  server_name localhost;

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

```

Is it not possible to have `init_by_lua_blocks` in the extra included configurations?

---

<div class="post-metadata">

### Author: ![hbagdi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/hbagdi/32/562_2.png) [@hbagdi](https://discuss.konghq.com/u/hbagdi)
#### Post date: [August 20, 2019, 4:22pm UTC](https://discuss.konghq.com/t/init-by-lua-block-configuration-in-kong-nginx-http-include-causes-start-up-errors/4264/2 "2019-08-20T16:22:20Z")

</div>

This is not possible.  
You will have to create a custom Nginx template and then pass it to Kong.

Please see: [https://docs.konghq.com/1.2.x/configuration/](https://docs.konghq.com/1.2.x/configuration/)
