Score:0

how to programatically set nginx configuration directives to nginx.conf?

jp flag

I am trying to make a shell script to auto install a web app and the script needs to set client_max_body_size to a bigger size, at some point.

Of course, it's possible to set this directive using nano but this is not what I am looking for. The script should be able to se the value for this directive in http section by itself.


The script needs to set mentioned directive in /etc/nginx/nginx.conf.

I have got this example in nginx docs, but I don't know how to modify this to my use-case:

nginx -g "pid /var/run/nginx.pid; worker_processes sysctl -n hw.ncpu;"

Tim avatar
gp flag
Tim
Can you simply copy the required config file over?
kindleuptake avatar
jp flag
yes, this is a possibility but I was wondering if the user has some directives /etc/nginx/nginx.conf that it needs to use. @Tim
Score:3
us flag

In many distributions, there is a include conf.d/*.conf line in nginx.conf http section.

So, the script can create a file in conf.d directory with .conf extension and the reload nginx configuration.

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.