Nginx ignores the include directive

configurationignorenginxvirtualhost

I'm currently migrating from Apache to nginx. I have a couple of domains that are going to be hosted on the same machine with one IP address. Though I've configured nginx --prefix=/my/path it seems that nginx doesn't include my vhost configuration files.

My current nginx.conf looks like this:

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"';

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip  on;

    # Don't show server version.
    server_tokens off;

    index index.html index.htm index.php;

    # Default server
    server {
        listen          81 default;
        server_name     _;
        access_log      logs/access.log main;
        server_name_in_redirect  off;
        root  html;
    }

    ## Load virtual host conf files. ##
    include conf/vhosts/*/*.conf; # config/vhosts/domain.com/domain.conf ; subodmain.conf and etc

}

And this is the only vhost config I have in config/vhosts/domain.com/domain.com.conf:

server {
    listen          81;
    server_name     domain.com;
    access_log      logs/domain.com.access.log main;

    root            "/www/domain.com/htdocs";
    index           index.html;
}

I also tried to set the absolute path to the config file but it didn't work either. All of the request are landing on the default server. If, though, you insert the content of conf/vhosts/domain.com/domain.com.conf into conf/nginx.conf http{} the domain works just fine.

I've been trying to figure this out for a couple of hours now but I guess I'm doing something wrong?

Best Answer

As the documentation states.

Since version 0.6.7, paths are relative to directory of nginx configuration file nginx.conf, but not to nginx prefix directory.

If you verify that the path is relative to the nginx configuration file does it then still not work?