[NGINX] root directive

Discussion in 'Installation/Configuration' started by andypl, Nov 20, 2014.

  1. andypl

    andypl Member

    Hi,

    I have a problem with setting the document root for certain projects.
    In the options I set this:
    root {DOCROOT} / public;
    but Nginx does not accept this configuration because the configuration is 2 times set the "root"
    I'm using version 1.6.1 Nginx.

    Regards
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Plesae try:

    server {##merge##
    root {DOCROOT} / public;
    }
     
  3. andypl

    andypl Member

    Not working i have this info on mail:

    20.11.2014-11:33 - WARNING - Reason for nginx restart failure: Restarting nginx: nginx failed!
    nginx: [emerg] "server" directive is not allowed here in /etc/nginx/sites-enabled/100-domain.tld.vhost:96
    nginx: configuration file /etc/nginx/nginx.conf test failed

    ISPConfig version 3.0.5.4 p5/ Nginx 1.6.1 dotdeb/ Debian Wheezy
     
    Last edited: Nov 20, 2014
  4. andypl

    andypl Member

    Remind myself :)
     
  5. KnechtRootRecht

    KnechtRootRecht New Member

    i have the same problem, server merge doesnt work.
    my domain-options look like:

    location / {
    root {DOCROOT}/public;
    try_files $uri $uri/ /index.php$is_args$args;

    }

    location @php { ##merge##
    root {DOCROOT}/public;
    }

    the Site works, but the session was not set when i go to the root-page.
    Its a Zend-Framework 1 Applikation, so i set the rewrite-rule and the public folder as document-root.
    when i edit the vhost manually and set:

    root /var/www/domain.tld/web/public;

    the Session is working on the root-page too.
    But every timethe the config was rewritten, this edit is resett.
    what can i do?
     
  6. andypl

    andypl Member

    I found the solution but also created a file vhost_ltd.err do not know why.
    Although this works.

    @till You can see why this is happening?
    I currently have ISPConfig 3.0.4.5p8 Debian Jessie Nginx 1.8.x

    Temporary solution:
    server { ##delete##
    root {DOCROOT};
    }

    server { ##merge##
    root {DOCROOT}/public;
    }
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    Check the generated vhost file and compare it with a working one to see whats different.
     
  8. andypl

    andypl Member

    diff output

    Code:
    7c7
    <         root   /var/www/domain.tld/web/public;
    ---
    >         root   /var/www/domain.tld/web;
    
    95a96,102
    >         server { ##delete##
    >               root /var/www/domain.tld/web;
    >         }
    >
    >         server { ##merge##
    >               root /var/www/domain.tld/web/public;
    >         }
    107c114
    < }
    ---
    > }
    
     
  9. djmendes

    djmendes New Member

    I am facing the same problem. Have you guys managed it to work?
     
  10. djmendes

    djmendes New Member

    digging in the ispconfig sources, I understood it only "merges" or "deletes" the location blocks, so I made the following workaround:

    Code:
    # redirecting everything to inner folder
    location / {
      root {DOCROOT}/public;
      try_files /public/$uri /public/$uri/ /public/index.php?$query_string;
    }
    
     

Share This Page