New2Python
New2Python

Reputation: 415

nginx: [emerg] "worker_processes" directive is not allowed here in /opt/tools/nginx/conf/nginx.conf:1

i cant figure out why I am getting this error. after looking at forums and many nginx examples my configs look good to me. I should mention I have a custom nginx install. I have check all the nginx log files but surprisingly they are empty.

I get this error:

nginx: [emerg] "worker_processes" directive is not allowed here in /opt/tools/nginx/conf/nginx.conf:1

When running this command:

/opt/tools/nginx/nginx -p /opt/tools/nginx

here is my structure of /opt/tools/nginx

.
├── client_body_temp
├── conf
│   ├── fastcgi.conf
│   ├── fastcgi_params
│   ├── koi-utf
│   ├── koi-win
│   ├── mime.types
│   ├── nginx.conf
│   ├── scgi_params
│   ├── uwsgi_params
│   └── win-utf
├── fastcgi_temp
├── html
│   └── favicon.ico
├── logs
│   └── error.log
├── nginx
├── proxy_temp
├── scgi_temp
├── ssl
│   ├── wildcard.tools.abc.com.crt
│   └── wildcard.tools.abc.com.key
└── uwsgi_temp

and here is my config file /opt/tools/nginx/conf/nginx.conf:

worker_processes 2;

daemon off;

error_log /opt/tools/log/nginx/error.log;

pid /opt/tools/nginx/nginx.pid;

events {
    worker_connections  256;
}

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

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /opt/tools/log/nginx/access.log  main;

    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     on;

    keepalive_timeout  65;

    gzip on;
    gzip_disable "msie6";
    server_tokens off;
    client_max_body_size 50M;


    server {
        listen       443 ssl;
        server_name  controller;

        ssl_certificate      /opt/tools/nginx/ssl/wildcard.tools.abc.com.crt;
        ssl_certificate_key  /opt/tools/nginx/ssl/wildcard.tools.abc.com.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;
        ssl_prefer_server_ciphers  on;

        # redirect server error pages to the static page /50x.html
        #
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root html;
        }

    }
    include /opt/tools/nginx/conf/*conf;
}

thanks

Upvotes: 1

Views: 9953

Answers (1)

Shawn C.
Shawn C.

Reputation: 6841

Your last command in your nginx.config is include /opt/tools/nginx/conf/*conf; which is attempting to load the /opt/tools/nginx/conf/nginx.conf for a second time but the second time it is included in the http block. Since worker_processes can not be in the http block it throws an error.

I would move your nginx.conf up one level to avoid this issue. Would require some other changes as well.

Upvotes: 2

Related Questions