Question

php-fpm security.limit_extension issue

I run Nginx + php5-fpm with Ajenti on Debian. This is the issue error.log gives me on one of the websites:

2015/03/16 10:44:03 [error] 1487#0: *95 FastCGI sent in stderr: “Access to the script ‘/srv/test/index.php/author-login’ has been denied (see security.limit_extensions)” while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: xxx.xx, request: “GET /index.php/author-login HTTP/1.1”, upstream: “fastcgi://unix:/var/run/ajenti-v-php-fcgi-test2-php-fcgi-0.sock:”, host: “xxx.xxx”, referrer: “xxx.xxx

How can I repair security.limit_exceptions?

Show comments

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
June 4, 2023
Pinned Answer

Heya,

In case anyone else stumlbes upon the questions years later here is a summary of the problem and solution

The security.limit_extensions setting in PHP-FPM configuration is used to limit which PHP scripts are allowed to run, based on their file extension. By default, it only allows .php files to be executed. This security measure prevents malicious or unintentional execution of non-PHP files.

The error message you’re seeing suggests that you’re trying to access a URL that appears to have a path appended to the PHP file (index.php/author-login). From the perspective of PHP-FPM, this looks like a file named index.php/author-login, which doesn’t match the .php file extension, hence the error.

To resolve this issue, you have two options:

  1. Modify your application’s URL structure: The preferred solution is to change your URL structure so that PHP scripts do not have paths appended. For example, use URL parameters (index.php?page=author-login) or URL rewriting instead.

  2. Adjust the security.limit_extensions setting: While less preferred for security reasons, you could technically adjust the security.limit_extensions setting to allow this type of request. This option should be used with caution as it can create security risks.

If you’re sure you want to take the second option, you can do this by editing the PHP-FPM pool configuration file for your site. This file is usually located in the /etc/php/8.0/fpm/pool.d/ directory (replace 8.04 with your PHP version). In the pool configuration file (something like www.conf), you’ll find the line:

security.limit_extensions = .php

To allow URLs with paths appended to PHP files, you could change it to:

security.limit_extensions = .php / 

This allows any file that ends with .php or / to be executed as a PHP script. However, again, be aware that this may have security implications, especially if your server ever encounters a situation where non-PHP files could be interpreted as having these extensions.

After making changes, you’ll need to reload or restart the PHP-FPM service to apply the changes:

sudo systemctl reload php8.0-fpm

Remember to replace 8.0 with your PHP version.

Just to add a simple fix for problems i was having. Mine was a small mistake in the nginx config that made PHP fpm try and deal with all the file (.js .jpg etc) This was because i had location / { all i had to do is change this so fpm only dealt with php files location ~ /.*\.php$ {

Andrew SB
DigitalOcean Employee
DigitalOcean Employee badge
March 17, 2015

FPM’s security.limit_extension setting is used to limit the extensions of the main script it will be allowed to parse. It prevents malicious code from being executed. The default value is simply .php It can be configured in /etc/php5/fpm/pool.d/www.conf

Though your issue like is elsewhere. The first thing I would check is that the cgi.fix_pathinfo setting in your /etc/php5/fpm/php.ini file is set to:

cgi.fix_pathinfo=0

See our tutorial on setting up Nginx and PHP for more info.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel