Overwrite nginx.conf option keepalive_timeout in http{} keeping default nginx.conf file

I have an nginx HTTP server in which I want to have keepalive_timeout 10s 10s;.

I would just add it in a file in /etc/nginx/conf.d/, however the default nginx.conf already contains keepalive_timeout 65s;, so if I simply do that, nginx complains because of defining that value twice.

So my workaround was to have a custom nginx.conf file where I removed that line, and then I could have my other file in conf.d. But it would be simpler if I could solve it without having to change the default file, so I would only have to add things into conf.d.

Is it possible anyhow?

Upvotes: 0

Views: 4564

Answers (1)

ofirule
ofirule

Reputation: 4659

According to the docs you can define the keepalive_timeout in any of http, server, location directives, so you can add keepalive_timeout 10s 10s; to your specific server or location directive and it will override the default.

Upvotes: 2

Related Questions