nginx: [emerg] “server” directive is not allowed here

前端 未结 4 1334
暖寄归人
暖寄归人 2020-11-29 20:52

I have reconfigured nginx but i can\'t get it to restart using the following config:

conf:

server {
listen 80;
server_name www.example.com;
return 30         


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-29 21:11

    That is not an nginx configuration file. It is part of an nginx configuration file.

    The nginx configuration file (usually called nginx.conf) will look like:

    events {
        ...
    }
    http {
        ...
        server {
            ...
        }
    }
    

    The server block is enclosed within an http block.

    Often the configuration is distributed across multiple files, by using the include directives to pull in additional fragments (for example from the sites-enabled directory).

    Use sudo nginx -t to test the complete configuration file, which starts at nginx.conf and pulls in additional fragments using the include directive. See this document for more.

提交回复
热议问题