Score:3

Changing Nginx NGX_CONF_BUFFER

pw flag

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 ?

Michael Hampton avatar
cz flag
Be careful. Do you _really_ need a variable of that length?
us flag
I think only nginx developers can answer this. It also might be that even they cannot answer. What is the actual problem you are trying to solve?
pw flag
We need add html page and return it with 200 status in nginx, but the html code length is higher than 4096, this html is includes some nginx variables so nginx print variables in html and send it to browser. is there any alternative method to serve html content that includes nginx variables?
Score:1
cn flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.