2

I'm seeing the "http" directive not allowed error from the logs. I have mounted "nginx-basic.conf" file in "conf.d" folder as a config mount in Kubernetes.

nginx-basic.conf-

http {
  server {
    location / {
      proxy_pass 35.239.243.201:9200;
      proxy_redirect off;
    }
  }

}

I'm not sure what is wrong with this. Could someone help me with pointing it out?

Ben Abey
  • 149
  • 2
  • 9
  • 1
    Possible duplicate of [nginx: \[emerg\] "server" directive is not allowed here](https://stackoverflow.com/questions/41766195/nginx-emerg-server-directive-is-not-allowed-here) – Richard Smith Nov 21 '18 at 19:16

1 Answers1

3

You probably have another http directive in a base nginx.conf that includes everything under /etc/nginx/conf.d

For example (nginx.conf):

user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        ...
        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

You can try removing the http directive:

server {
  location / {
    proxy_pass 35.239.243.201:9200;
    proxy_redirect off;
  }
}
Rico
  • 58,485
  • 12
  • 111
  • 141