Welcome! Log In Create A New Profile

Advanced

Re: NGINX PHP FPM - Download prompt when accessing directories

Francis Daly
August 30, 2020 07:10PM
On Sun, Aug 30, 2020 at 04:43:27PM +0000, Laura Smith wrote:

Hi there,

> I have a largely working NGINX config as below.  The only problem is that when "/administrator" or "/administrator/" or "administrator/foo.php" is called, I always get prompted to download the PHP file rather than it be executed by PHP FPM.  Meanwhile, calls to "/" or "/foo.php" operate as expected  (i.e. executed correctly by PHP FPM).
>

In nginx, one request is handled in one location{}.

Your

>       location ^~ /administrator/ {

will handle all requests that start with /administrator/; that location
does not do any special handling of php requests; all it will do is
serve files from the filesystem.

Depending on how you want the requests handled, possibly removing the
"^~" will work (that would mean that any requests that match other
regex-location{}s will not be handled in this location); or possibly
creating a nested regex location for "~php" within this location will
work (with contents very like the "main" php location).


(Your config seems to want basic authentication for "file" requests,
but not for "php" requests; that may well be what you intend.) (And the
limit_except lines seem redundant with the "if ($request_method" line;
but if what you have works, it works.)

Good luck with it,

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Re: NGINX PHP FPM - Download prompt when accessing directories

Francis Daly August 30, 2020 07:10PM

Re: NGINX PHP FPM - Download prompt when accessing directories

Francis Daly August 31, 2020 04:02AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 71
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready