Wordfence auto_prepend_file nginx

Discussion in 'ISPConfig 3 Priority Support' started by Norman, May 30, 2022.

  1. Norman

    Norman Member HowtoForge Supporter

    Hi,

    What would be the equivilent directive on nginx to auto_prepend_file ?

    In user.ini + .htaccess method on apache2 it's:
    auto_prepend_file = '/path/to/waf/wordfence-waf.php'

    But how would auto_prepend_file work on nginx with directives?
    A stackoverflow post recommends :
    location ~ \.php$ {
    expires off;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /var/www//httpdocs/$fastcgi_script_name;
    fastcgi_param PHP_VALUE "auto_prepend_file=/var/www/your_folder/Resources/Core.php";
    }

    But this overrides the @php stanza of ISPconfig in the vhost. Is there a better way?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Try using the custom php.ini field on the options tab of the website to configure PHP for this website:

    auto_prepend_file = '/path/to/waf/wordfence-waf.php'

    or use built-in nginx config modification options in ISPConfig to modify the location, never try to override it as Nginx does not support overriding and will stop working then.
     
  3. Norman

    Norman Member HowtoForge Supporter

    Thank you, I've told the developer of the page to do this.
     
  4. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    You can also set some php options via ini files, eg. the standard .user.ini that wordfence creates should work when the request to the php-fpm daemon is made by either apache or nginx, as it is read by the php daemon, not the webserver (the path is for chroot mode php-fpm):
    Code:
    $ cat /web/.user.ini
    ; Wordfence WAF
    auto_prepend_file = '/web/wordfence-waf.php'
    ; END Wordfence WAF
    
     
    Last edited: May 31, 2022

Share This Page