Changing Nginx NGX_CONF_BUFFER

When try to set long characters variables in Nginx it show error due to limit in NGX_CONF_BUFFER 4096 Reference: https://github.com/nginx/nginx/blob/master/src/core/ngx_conf_file.c

var set: set $q 'aaaaa........till 5000 characters include white space'; error: too long parameter, probably missing terminating "'"

is it safe to change NGX_CONF_BUFFER to 8192 0r 10240 before compile Nginx to avoid such error ?


Solution 1:

As Michael suggested, you probably don't need a variable that length. NGX_CONF_BUFFER defines the maximum line length in nginx.conf file. You really should not need to define a configuration variable with that much data. Configuration files should be concerned with endpoints, headers, content-types, etc, in other words meta-data.

For your use case, to serve dynamic content managed by NGINX, you might consider using NGINX Javascript or NJS, see https://nginx.org/en/docs/njs/ - see more examples and get started here: https://github.com/nginx/njs-examples.