T
T
theSever2016-12-12 20:14:30
Nginx
theSever, 2016-12-12 20:14:30

Errors in Nginx configs, how to fix?

In short, I put a bunch of Apache + Nix. Now it gives out a nix page when entering the domain. I'm trying to set up configs for each site, I went through a cloud of options, but the result is the same everywhere - [[email protected] ~]# /etc/init.d/nginx restart
nginx: [emerg] unknown directive "server" in /etc/nginx/conf.d /site.com.conf:1
nginx: configuration file /etc/nginx/nginx.conf test failed
nginx.conf

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections  1024;
}


http {
    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  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

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

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;
  include /usr/local/ispmgr/etc/nginx.domain;
  client_max_body_size 16M;
}

One of the site.com.conf options
server {

    listen          ip_servera:80;
    server_name     www.my-site.ru my-site.ru;

    access_log  /var/www/user/data/my-site.ru/logs/my-site.ru.access.log;
    error_log  /var/www/user/data/my-site.ru/logs/my-site.ru.error.log;

    location /
    {
        proxy_pass http://127.0.0.1/;
        proxy_read_timeout 600;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header  X-Forwarded-For   $remote_addr;
        proxy_buffering off;
    }
    location ~* .(txt|jpg|jpeg|gif|mpg|mpeg|avi|png|css|swf|ico|zip|rar|sdt|js|bmp|wav|mp3|mmf|mid|vkp|sisx|sis|exe|jar|thm|nth|doc)$ {
        root /home/test.ru/html;
        expires 2d;
    }

}

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
A
Alexey, 2016-12-12
@theSever

I created your configs on a test system, did it nginx -t- writes syntax is ok.
It is necessary to look at the files in detail - there may be a BOM character at the beginning or some other non-printable character.
Try inserting a newline before the server, it might help.

O
OnYourLips, 2016-12-12
@OnYourLips

include /usr/local/ ispmgr /etc/nginx.domain;
Where did this come from? It probably ruins everything.
Set yourself default configs, everything will work fine with them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question