I get the following error message when trying to configure server:

[]# nginx -s reload
nginx: [emerg] "server" directive is not allowed here in /etc/nginx/conf.d/hello-world.conf:1

Configuration is as follows:


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

    index   index.html index.htm;

    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        server_name  localhost;
        root         /usr/share/nginx/html;
        location / {


server {
    listen 80;
    server_name my.server;

    root    i/var/www/hello-world;
    index   index.html;

    location / {

nginx version: nginx/1.6.2 OS: CentOS-70-64-minimal

I suppose it doesn't get that server directive is inside http because when I copy content of hello-world.conf to nginx.conf right after include it works.

Can anyone help me please?

  • Looks like a possible problem with something in one or more of the include files. – mdpc Mar 16 '15 at 2:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.