Nginx and modern PHP frameworks problem

Discussion in 'Installation/Configuration' started by jang, Jun 11, 2015.

  1. jang

    jang New Member

    Most modern PHP frameworks (Laravel, Phalcon) have a project root (web) and a document root (web/public).
    Only the document root is accessible by web, and the project root is for composer, git and source files.
    (Tested it on a server Ubuntu 14.04 LTS and Nginx)

    ISPconfig3 has a default web directory, setup as document root.
    IMHO we need a setting in ISPcongif3 -> sites to set the root in Nginx to web/public instead of web.
    There are suggestions by Till how to do that but they do not work here, the only thing that works is editing ` /etc/nginx/sites-enabled/100-xx.vhost` and set the root manually, but that doesn't last.

    Adding another
    location / {
    root {docroot}/public
    }​
    sets the root only for that part.

    Furthermore I guess, more features to enable tweaking Nginx conf settings are needed / welcome.
    Of course a solution could be changing all your projects to work with the private folder, but that is a nuisance every time.

    So, is there a solution/workaround to change document root to web/public?
    The only hack I came with is manually copy /etc/nginx/sites-available/xx.vhost to /etc/nginx/sites-enabled/000-x.vhost so it will override the 100-x.vhost added by ISPconfig.

    Having web as document and project root for modern PHP frameworks is really insecure, IMHO it makes ISPconfig3 a bad choice for modern PHP frameworks, at least with default setup.
     
    Last edited: Jun 11, 2015
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Edit the nginx vhost template master file.
     
  3. jang

    jang New Member

    Thx Till, will try that out.
    Is this the file?

    /usr/local/ispconfig/server/conf/nginx_vhost.conf.master

    Will it be overridden with an update of ISP3config? Can I copy it to conf-custom, or is that a wrong idea?
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    yes.

    Yes, the modified file should be stored in conf-custom toprevent that iz gets overridden on updates.
     
  5. jang

    jang New Member

    Thx, great help.
    Do you consider making this setting default or at least an installation option?
    IMHO It's good practice to limit the amount of PHP files in the document root. A different project and document root is really an improvement and for modern deployment a must.
     

Share This Page