Welcome! Log In Create A New Profile

Advanced

Restrict PHP execution

Posted by David Blank-Edelman 
David Blank-Edelman
Restrict PHP execution
January 15, 2013 05:12PM
Hi-
I suspect this is a simple (read: stupid) question, but is there a
PHP-FPM equivalent to the mod_php directive for restricting PHP execution,
i.e.:

<Directory ${WWWDOCROOT}>
...
php_admin_flag engine off

...
</Directory>

I realize I can block access to files with a .php suffix so it never reaches FPM, but is there a closer equivalent? Thanks!

-- dNb
Anatoly Pashin
Re: Restrict PHP execution
January 16, 2013 12:20AM
IMHO you should not do that on backend.
You should do that in nginx's conf or what else you use for frontend.

2013/1/16 David Blank-Edelman <dnblankedelman@gmail.com>

> Hi-
> I suspect this is a simple (read: stupid) question, but is there a
> PHP-FPM equivalent to the mod_php directive for restricting PHP execution,
> i.e.:
>
> <Directory ${WWWDOCROOT}>
> ...
> php_admin_flag engine off
>
> ...
> </Directory>
>
> I realize I can block access to files with a .php suffix so it never reaches FPM, but is there a closer equivalent? Thanks!
>
> -- dNb
>
>
>
António P. P. Almeida
Re: Restrict PHP execution
January 17, 2013 04:00AM
On 15 Jan 2013 20h39 CET, dnblankedelman@gmail.com wrote:

> Hi- I suspect this is a simple (read: stupid) question, but is there
> a PHP-FPM equivalent to the mod_php directive for restricting PHP
> execution, i.e.:
>
> <Directory ${WWWDOCROOT}>
> ...
> php_admin_flag engine off
>
> ...
> </Directory>
>
> I realize I can block access to files with a .php suffix so it never
> reaches FPM, but is there a closer equivalent? Thanks!

As Anatoly already said: the problem should be posed differently. That
is, you should enumerate your PHP scripts or find a way to constrain
execution to specific patterns, so that *those and only those* files
are sent to FCGI. Then as a final measure just add a regex based
location like this:

location ~* \.php$ {
return 404;
}

--- appa
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 249
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready