Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"worker_processes" directive is not allowed nginx

Tags:

nginx

config

akka

I need to create nginx.conf file with such routes: /assets - static files, /akka - for hello-world akka webapp, /* - default page. My default.conf file looks like this:

worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}

http {
    include mime.types;
    default_type  application/octet-stream;

    upstream hello-akka{
        server localhost:9000;
    }

    server {
        listen 80;

        location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
        }

        location /akka {
        proxy_pass http://hello-akka;
        }

        location /assets {
        root /var/www;
        }   
    }
}

Every time I restart nginx service I get these error messages:

nginx: [emerg] "worker_processes" directive is not allowed here in /etc/nginx/conf.d/default.conf:2
nginx: configuration file /etc/nginx/nginx.conf test failed

I checked the structure of the file itself and I can't figure out what is wrong. Even when I delete this line I get the same "directive is not allowed" error but for other lines like pid, events and so on. So how can I fix such error?

like image 810
Cassie Avatar asked Dec 04 '17 20:12

Cassie


Video Answer


1 Answers

Put that directive at the top of the /etc/nginx/nginx.conf instead of /etc/nginx/conf.d/default.conf.

The worker_processes directive is valid only at the top level of the configuration.

Now it comes by default in /etc/nginx/nginx.conf.

like image 123
Ashish Tiwari Avatar answered Sep 21 '22 14:09

Ashish Tiwari