question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"worker_connections" directive is not allowed here

See original GitHub issue

TLDR: How can I update the nginx configuration to use 10k worker_connections? Is there a way to change the nginx configuration other than building another image based on this one (https://github.com/jwilder/nginx-proxy/issues/464)?

We are running this docker in production, and are now reaching the following error:

2017/11/09 15:04:38 [alert] 33#33: 1024 worker_connections are not enough
2017/11/09 15:04:38 [alert] 33#33: 1024 worker_connections are not enough
2017/11/09 15:04:38 [alert] 33#33: 1024 worker_connections are not enough
2017/11/09 15:04:38 [alert] 33#33: 1024 worker_connections are not enough
2017/11/09 15:04:38 [alert] 33#33: 1024 worker_connections are not enough
2017/11/09 15:04:38 [alert] 33#33: 1024 worker_connections are not enough
2017/11/09 15:04:38 [alert] 33#33: 1024 worker_connections are not enough
2017/11/09 15:04:38 [alert] 33#33: 1024 worker_connections are not enough
2017/11/09 15:04:38 [alert] 33#33: 1024 worker_connections are not enough
2017/11/09 15:04:38 [alert] 33#33: 1024 worker_connections are not enough
2017/11/09 15:04:38 [alert] 33#33: 1024 worker_connections are not enough

I would like to increase the number of worker_connections to a higher number, as stated in https://serverfault.com/questions/787919/optimal-value-for-nginx-worker-connections

I updated my_proxy.conf to:

$ cat my_proxy.conf
events {
  worker_connections 10000;
}
$ docker run -p 80:80 \
  -v /var/run/docker.sock:/tmp/docker.sock:ro \
  -v /home/cadesalaberry/Apps/industrial/setup/nginx/my_proxy.conf:/etc/nginx/conf.d/my_proxy.conf:ro \
  jwilder/nginx-proxy

WARNING: /etc/nginx/dhparam/dhparam.pem was not found. A pre-generated dhparam.pem will be used for now while a new one
is being generated in the background.  Once the new dhparam.pem is in place, nginx will be reloaded.
forego     | starting dockergen.1 on port 5000
forego     | starting nginx.1 on port 5100
nginx.1    | 2017/11/09 15:08:42 [emerg] 37#37: "events" directive is not allowed here in /etc/nginx/conf.d/my_proxy.conf:3
forego     | starting nginx.1 on port 5200
forego     | sending SIGTERM to nginx.1
forego     | sending SIGTERM to dockergen.1

Then tried to put worker_connections at the root:

$ cat my_proxy.conf
events {
  worker_connections 10000;
}
$ docker run -p 80:80 \
  -v /var/run/docker.sock:/tmp/docker.sock:ro \
  -v /home/cadesalaberry/Apps/industrial/setup/nginx/my_proxy.conf:/etc/nginx/conf.d/my_proxy.conf:ro \
  jwilder/nginx-proxy
WARNING: /etc/nginx/dhparam/dhparam.pem was not found. A pre-generated dhparam.pem will be used for now while a new one
is being generated in the background.  Once the new dhparam.pem is in place, nginx will be reloaded.
forego     | starting dockergen.1 on port 5000
forego     | starting nginx.1 on port 5100
nginx.1    | 2017/11/09 15:08:56 [emerg] 32#32: "worker_connections" directive is not allowed here in /etc/nginx/conf.d/my_proxy.conf:3
nginx.1    | nginx: [emerg] "worker_connections" directive is not allowed here in /etc/nginx/conf.d/my_proxy.conf:3
forego     | starting nginx.1 on port 5200
forego     | sending SIGTERM to nginx.1
forego     | sending SIGTERM to dockergen.1

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
MicahZoltucommented, Jul 20, 2018

Can you provide more details on how one actually goes about implementing this workaround? I want to use all of nginx-proxy’s normal configuration except I want to increase the worker_connections count. Where is this nginx.conf file I need to replace? Is the file static or auto-generated when I create/destroy docker containers that nginx is monitoring?

1reaction
taxiliancommented, May 10, 2018

The reason it doesn’t work is that conf.d/* is included from the “http” directive in the container-provided nginx.conf file.

You could either fork the repo or you could use docker’s -v to map a replacement nginx.conf file over the default one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"worker_processes" directive is not allowed nginx
The worker_processes directive is valid only at the top level of the configuration. Now it comes by default in /etc/nginx/nginx.conf .
Read more >
"worker_connections" directive is not allowed here · Issue #971
The reason it doesn't work is that conf.d/* is included from the "http" directive in the container-provided nginx.conf file. You could either ...
Read more >
nginx: worker_proccesses directive doesn't work - Server Fault
You said that your error message was: nginx: [emerg] "worker_processes" directive is not allowed here in /etc/nginx/sites-enabled/default:1 nginx: ...
Read more >
nginx: [emerg] "server" directive is not allowed here in /etc ...
Hi there, i got error when running nginx -t the result is nginx: [emerg] “server” directive is not allowed here in ...
Read more >
Setting up and Troubleshooting Your Nginx Server on Alibaba ...
"worker_connections" directive is not allowed here in /etc/nginx/nginx.conf:12 nginx: configuration file /etc/nginx/nginx.conf test failed.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found