Join the community today
Become a Member

Domain related nginx conf files in /home/nginx/...

Discussion in 'Feature Requests & Suggestions' started by ethanpil, Jan 27, 2016.

Tags:
  1. ethanpil

    ethanpil Active Member

    173
    55
    28
    Nov 8, 2015
    Ratings:
    +101
    Local Time:
    12:07 PM
    Currently, the nginx config files are a bit messy, IMHO. Besides the main nginx conf files for each domain, we have
    • /usr/local/nginx/conf/conf.d
      • domain.com.conf
      • domain.ssl.com.conf
    • /usr/local/nginx/conf
      • wpcacheenabler_domain.com.conf
      • wpsecure_domain.com.conf
      • wpsupercache_domain.com.conf
      • rediscache_domain.com.conf
    I was thinking it would be quite convenient to store the nginx .conf files for each domain together with the other stuff...


    In /home/nginx/domains/domain.com we already have
    • /public
    • /private
    • /log
    • /backup
    Why not just place the doman related config files in there? Something like this...
    • /conf
      • domain.com.conf
      • domain.ssl.com.conf
      • /inc
        • wpcacheenabler_domain.com.conf
        • wpsecure_domain.com.conf
        • wpsupercache_domain.com.conf
        • rediscache_domain.com.conf
    What do you think?
     
  2. eva2000

    eva2000 Administrator Staff Member

    53,506
    12,132
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,675
    Local Time:
    12:07 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    The way it's done now is outlined at Nginx - Developer Overview: How Nginx is installed on Centmin Mod LEMP stack | Centmin Mod Community as nginx /usr/local/nginx/conf is auto backed up every time you upgrade or download nginx via centmin.sh.

    It also makes automation of the routines easier to do. Also folks are more likely to edit or remove files within their own /home/nginx/domains/domain.com/ directories. Another reason is if you provide Pure-FTPD virtual ftp access to users other than yourself, then you open up access to server level configuration files to other users who can edit or at least read your server configuration files.
     
  3. ethanpil

    ethanpil Active Member

    173
    55
    28
    Nov 8, 2015
    Ratings:
    +101
    Local Time:
    12:07 PM
    What do you think about organizing better in /usr/local/nginx/conf ?
    Perhaps subfolders for every domain and keeping the files together there?

    Also, maybe adding a symlink to that folder in /home/nginx/domains/domain.com/conf
    Coudn't we use the symlink to prevent ftp access?
     
    Last edited: Jan 27, 2016
  4. eva2000

    eva2000 Administrator Staff Member

    53,506
    12,132
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,675
    Local Time:
    12:07 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    In all honesty keeping configure files out of /home/nginx/domains/domain.com will always be the way Centmin Mod will be developed. You can always manually symlink the config files yourself if you want convenient, or setup alias cmds or cmd shortcuts yourself (see FAQ item 16). The default ones you can see at centminmod/shortcuts_install.inc at 123.08stable · centminmod/centminmod · GitHub

    i.e. to edit /usr/local/nginx/conf/nginx.conf just type nginxconf
    Code:
    echo "nano -w /usr/local/nginx/conf/nginx.conf" >/usr/bin/nginxconf ; chmod 700 /usr/bin/nginxconf
    Code:
    cat /usr/bin/nginxconf
    nano -w /usr/local/nginx/conf/nginx.conf
    possibly for just the wordpress centmin.sh menu option 22 specific files like
    • wpcacheenabler_domain.com.conf
    • wpsecure_domain.com.conf
    • wpsupercache_domain.com.conf
    • rediscache_domain.com.conf
    but the other include files are global includes for each vhost so need to be to in /usr/local/nginx/conf
     
  5. eva2000

    eva2000 Administrator Staff Member

    53,506
    12,132
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,675
    Local Time:
    12:07 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    FYI 123.09beta01 has updated inc/wpsetup.inc for centmin.sh menu option 22 update inc/wpsetup.inc for 123.09beta01 · centminmod/centminmod@402f43d · GitHub

    move centmin.sh menu option 22 wordpress generated include files from /usr/local/nginx/conf to their own specific directories at /usr/local/nginx/conf/wpincludes/$vhostname directory

    example for centmin.sh menu option 22 wordpress install for newdomain2.com
    Code:
    ls -lah /usr/local/nginx/conf/wpincludes/newdomain2.com/
    total 24K
    drwxr-x--- 2 root root 4.0K Jan 27 00:06 .
    drwxr-x--- 3 root root 4.0K Jan 27 00:06 ..
    -rw-r--r-- 1 root root 1009 Jan 27 00:06 rediscache_newdomain2.com.conf
    -rw-r--r-- 1 root root 1.2K Jan 27 00:06 wpcacheenabler_newdomain2.com.conf
    -rw-r--r-- 1 root root 1.1K Jan 27 00:06 wpsecure_newdomain2.com.conf
    -rw-r--r-- 1 root root  489 Jan 27 00:06 wpsupercache_newdomain2.com.conf
    vhost contents /usr/local/nginx/conf/conf.d/newdomain2.com.conf
    Code:
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html
    
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    #server {
    #            listen   80;
    #            server_name newdomain2.com;
    #            return 301 $scheme://www.newdomain2.com$request_uri;
    #       }
    
    server {
    
      server_name newdomain2.com www.newdomain2.com;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/newdomain2.com/log/access.log combined buffer=256k flush=60m;
      error_log /home/nginx/domains/newdomain2.com/log/error.log;
    
      root /home/nginx/domains/newdomain2.com/public;
    
      include /usr/local/nginx/conf/wpincludes/newdomain2.com/wpcacheenabler_newdomain2.com.conf;
      #include /usr/local/nginx/conf/wpincludes/newdomain2.com/wpsupercache_newdomain2.com.conf;
      # https://community.centminmod.com/posts/18828/
      #include /usr/local/nginx/conf/wpincludes/newdomain2.com/rediscache_newdomain2.com.conf; 
    
      location / {
    
    
      # Enables directory listings when index file not found
      #autoindex  on;
    
      # for wordpress super cache plugin
      #try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?q=$uri&$args;
    
      # for wp cache enabler plugin
      try_files $cache_enabler_uri $uri $uri/ $custom_subdir/index.php?$args;  
    
      # Wordpress Permalinks
      #try_files $uri $uri/ /index.php?q=$uri&$args;
    
      # Nginx level redis Wordpress
      # https://community.centminmod.com/posts/18828/
      #try_files $uri $uri/ /index.php?$args;
    
      }
    
    location ~* /(wp-login\.php) {
        limit_req zone=xwplogin burst=1 nodelay;
        #limit_conn xwpconlimit 30;
        #auth_basic "Private";
        #auth_basic_user_file /home/nginx/domains/newdomain2.com/htpasswd_wplogin; 
        include /usr/local/nginx/conf/php-wpsc.conf;
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
    location ~* /(xmlrpc\.php) {
        limit_req zone=xwprpc burst=45 nodelay;
        #limit_conn xwpconlimit 30;
        include /usr/local/nginx/conf/php-wpsc.conf;
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
      include /usr/local/nginx/conf/wpincludes/newdomain2.com/wpsecure_newdomain2.com.conf;
      include /usr/local/nginx/conf/php-wpsc.conf;
      # https://community.centminmod.com/posts/18828/
      #include /usr/local/nginx/conf/php-rediscache.conf;
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }
     
    Last edited: Jan 27, 2016
  6. ethanpil

    ethanpil Active Member

    173
    55
    28
    Nov 8, 2015
    Ratings:
    +101
    Local Time:
    12:07 PM
    Thanks for that will make life less cluttered! :)