Kong: nginx directives can be set from kong.conf

Anything Kong does not expose as a setting can still be injected into the generated nginx configuration using the nginx_http_, nginx_proxy_ and nginx_server_ prefixes.

Code
# kong.conf
nginx_http_client_max_body_size = 20m
nginx_http_client_body_buffer_size = 1m
nginx_proxy_proxy_buffering = off          # stream responses
nginx_http_log_format = json escape=json '{"ip":"$remote_addr"}'

# as environment variables, for a container
KONG_NGINX_HTTP_CLIENT_MAX_BODY_SIZE=20m

# see what Kong generated
kong prepare && cat /usr/local/kong/nginx-kong.conf
Output
# The prefix maps to a block:
#   nginx_http_*   -> http { }
#   nginx_proxy_*  -> the proxy server { }
#   nginx_admin_*  -> the admin server { }
#
# client_max_body_size is the one that catches people: request-size-limiting
# returns a clean JSON 413, but nginx's own limit fires first and returns an
# HTML error page. Set the nginx value at or above the plugin's.
Advertisement

Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.

Published 2026-08-25