requested file could not be found error

requested file could not be found error

Ben Thomas -
回帖数:6
I currently have moodle set up behind Apache 2 with the following configuration:
Ubuntu 14.04
Apache/2.4.12
PHP 5.5.23-1+deb.sury.org~trusty+2

I am having an issue with assets that contain a space (urlencoded to %20) in the file name, for example:

When requesting this I get a "Sorry, the requested file could not be found" error however by disabling slash arguments in moodle (and not changing server config at all) the images are displayed.  This only seems to effect images with a space in their file name and I am not having trouble getting assets and things with or without slash arguments enabled.

I am testing upgrading from CGI PHP to FPM and this is a sticking point so far.  I have the following settings changed from default in PHP:

 error_log syslog
 memory_limit 2048M
 cgi.fix_pathinfo 1
 upload_max_filesize 2000M
 post_max_size 2000M
 max_execution_time 480
 realpath_cache_size 1M
 realpath_cache_ttl 300
 opcache.enable 1
 opcache.memory_consumption 2048M
 opcache.interned_strings_buffer 16
 opcache.max_accelerated_files 8000
 opcache.use_cwd 1
 opcache.validate_timestamps 1
 opcache.revalidate_freq 60
 opcache.save_comments 1
 opcache.enable_file_override 0


This is the ProxyPass line I am using:

ProxyPassMatch "^/(.*\.php(/.*)?)$" "fcgi://127.0.0.1:9000:/var/www/$1" enablereuse=on nocanon

I am not sure what is breaking it, it doesn't seem to be permissions or PHP/Apache config since slash everything works without slash arguments configured.  Any thoughts would be helpful!

回复Ben Thomas

Re: requested file could not be found error

Howard Miller -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像

Two questions...

1. Can you tell us how to reproduce this error (that is, how have these things with spaces been loaded into Moodle in the first place) in detail?

2. What is that ProxyPassMath line supposed to do? Why do you need it - or think you need it?

回复Howard Miller

Re: requested file could not be found error

Ben Thomas -

Sure:


1. These are any images that are in the theme, I didn't build the theme or anything, I am just the server admin for this site so I am not sure how the theme was built.

2. ProxyPassMatch is how you tell Apache to send requests for whatever matches the regex (PHP files in this case) to a backed (php-fpm in this case) using mod_proxy.  mod_proxy is the recommended way to use php-fpm as of Apache 2.4 (as opposed to mod_fastcgi as previous).  More info here: http://httpd.apache.org/docs/trunk/mod/mod_proxy_fcgi.html

回复Ben Thomas

Re: requested file could not be found error

Howard Miller -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像

1. Do you get the same problem if you switch to a standard/core theme?

2. Yes, I know what it is. Sorry I should have been more clear - why do you have it and why have you mentioned it in this context? Presumably you think it's something to do with your issue?

回复Howard Miller

Re: requested file could not be found error

Ben Thomas -

I will try the classic theme and get back to you.


I have it here because that is how Apache knows to send requests for PHP files to PHP-FPM and I was just being thorough and showing all parts of the configuration that I thought were relevant to this issue and I thought maybe my regex or parameters might be wrong.

回复Howard Miller

Re: requested file could not be found error

Ben Thomas -

Figured it out, ProxyPassMatch doesn't decode the %20 so Moodle receives the path to the file including the %20 and for some idiotic reason file name.txt and file%20name.txt are different to Moodle (result in different hashes in the DB so moodle can't find the file since it doesn't un-escape it before hashing). 

Anyway, solution can be found here (using sethandler instead of proxy pass match):

https://moodle.org/mod/forum/discuss.php?d=277683#p1200619