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?

2 Answers 2


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?

  • Ahhh... I though it was relative to the root directory of nginx. Now it works fine! But I'm curious why it doesn't work with absolute paths? What happens if these files are outside nginx's home?
    – tftd
    Apr 30, 2012 at 16:22
  • 1
    Then it won't work. Nginx isn't a "have it however you want" it's a "this is how it works and that allows us to be slim and fast, fit in." Rough in some situations but appreciated in others, generally it's not really a bother. Apr 30, 2012 at 16:39

The answer above is wrong as of now. According to the docs:

nginx uses absolute paths only, all relative paths in configuration files are relative to --prefix==PATH.



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .