Learn about Centmin Mod LEMP Stack today
Register Now

Nginx Custom configuration locations?

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by joshuah, Apr 25, 2017.

  1. joshuah

    joshuah Member

    121
    14
    18
    Apr 3, 2017
    Ratings:
    +17
    Local Time:
    11:47 AM
    Hello,

    Just wondering where I would put custom nginx configurations so it wont get overwritten upon upgrade?

    Wanting to put the following:

    Code:
    # Block PHP files in uploads directory.
    location ~* /(?:uploads|files)/.*\.php$ {
      deny all;
    }
    # Block PHP files in content directory.
    location ~* /wp-content/.*\.php$ {
      deny all;
    }
    # Block PHP files in includes directory.
    location ~* /wp-includes/.*\.php$ {
      deny all;
    }
    # Block PHP files in uploads, content, and includes directory.
    location ~* /(?:uploads|files|wp-content|wp-includes)/.*\.php$ {
      deny all;
    }
    
     
  2. eva2000

    eva2000 Administrator Staff Member

    30,883
    6,907
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,400
    Local Time:
    10:47 AM
    Nginx 1.13.x
    MariaDB 5.5
    centmin.sh menu option 2 already adds all those to the wpsecure_yourdomain.com.conf include files.
     
  3. joshuah

    joshuah Member

    121
    14
    18
    Apr 3, 2017
    Ratings:
    +17
    Local Time:
    11:47 AM
    I am looking for more of a global config for all websites? As most of my websites are being installed under option 22.
     
  4. eva2000

    eva2000 Administrator Staff Member

    30,883
    6,907
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,400
    Local Time:
    10:47 AM
    Nginx 1.13.x
    MariaDB 5.5
    then just make a copy of one of the include files for wpsecure_yourdomain.com.conf as wpsecure_global.conf and then edit each wordpress nginx vhost's include file to change from wpsecure_yourdomain.com.conf to wpsecure_global.conf

    centmin mod doesn't touch your nginx vhost itself once created.
     
  5. joshuah

    joshuah Member

    121
    14
    18
    Apr 3, 2017
    Ratings:
    +17
    Local Time:
    11:47 AM
    Thanks. So there is no way to have a custom global config for every website?

    i.e. is it possible to have it so that wpsecure_global.conf pre-exists but is empty and all websites are pointing to that. As I desire to have some rules preset for all virtualhosts without needing to make adjustments to every virtualhost (each time, etc.).
     
  6. eva2000

    eva2000 Administrator Staff Member

    30,883
    6,907
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,400
    Local Time:
    10:47 AM
    Nginx 1.13.x
    MariaDB 5.5
    what i outlined is the way to make a config include file globally available

    but you mean editing pre-existing template not easily but can be do if you script it yourself - there is some basic ground work already available https://community.centminmod.com/th...menu-option-22-installs-in-123-09beta01.8119/

    so you create your own
    mywpcmds bash shell function in a file /etc/centminmod/customwp_domain.com.inc https://community.centminmod.com/threads/update-inc-wpsetup-inc-add-new-mywpcmds-routine.6080/

    and script it to comment out or replace existing wpsecure_yourdomain.com.conf and with wpsecure_global.conf