• Resolved PumpaXXL

    (@pumpaxxl)


    Hi, our host allows multiple web sites per one account but all websites can have only one prepend file which is common for all of them. So my question is if it is possible to activate Full WAF mode for all the sites using the same auto_prepend_file (from one of them).

    Thank you,
    Pavel

    Great plugin BTW.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author nintechnet

    (@nintechnet)

    You can have multiple WordPress installations with one PHP INI. But you need to do some work.
    Here’s an example: https://blog.nintechnet.com/installing-ninjafirewall-with-hhvm-hiphop-virtual-machine/
    Scroll down to the “Multiple-site installation” section. Although this article refers to HHVM, the problem is the same: installing multiple instances of NinjaFirewall with one single PHP INI.

    Assuming you have 3 sites as per follows:

    └── /home
      └── /user
          ├── /domain_01.tld
          │
          ├── /domain_02.tld
          │
          └── /domain_03.tld
    

    1. Install NinjaFirewall on “domain_01.tld”, and load it from /home/user/.user.ini (or php.ini depending on your host).
    2. After the installation, comment out the auto_prepend_file directive to temporarily disable the firewall.
    3. Repeat steps 1 and 2 with all other sub-domains.
    4. Create a PHP script in your root folder, e.g., /home/user/my_script.php.
    5. Add this code to it and adjust the paths accordingly:

    
    <?php
    // Prepend the firewall for domain_01.tld:
    if (strpos($_SERVER['SCRIPT_FILENAME'], '/home/user/domain_01.tld') !== false) {
       // Load the firewall:
       require('/home/user/domain_01.tld/wp-content/nfwlog/firewall.php');
    
    // Prepend the firewall for domain_02.tld:
    } elseif (strpos($_SERVER['SCRIPT_FILENAME'], '/home/user/domain_02.tld') !== false) {
       // Load the firewall:
       require('/home/user/domain_02.tld/wp-content/nfwlog/firewall.php');
    
    // Prepend the firewall for domain_03.tld:
    } elseif (strpos($_SERVER['SCRIPT_FILENAME'], '/home/user/domain_03.tld') !== false) {
       // Load the firewall:
       require('/home/user/domain_03.tld/wp-content/nfwlog/firewall.php');
    }
    

    6. Load the above script from the PHP INI auto_prepend_file directive:

    ; BEGIN NinjaFirewall
    auto_prepend_file = /home/user/my_script.php
    ; END NinjaFirewall
    
    Thread Starter PumpaXXL

    (@pumpaxxl)

    Great, thanks!
    Pavel.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multiple Websites Using One Prepend File’ is closed to new replies.