Running Moodle with nginx in userdir (slash arguments)
I am moving Moodle (moodle.org) from an Apache host to a Ubuntu 12.04 LTS
host running Nginx. The way the host is set up means that it will running
quite a few domains where every domain (or other site) will reside in a
user dir.
I am running Nginx with php5-fpm. I found quite a few configurations for
running php-fpm inside a user dir, which all work. The problem however is
that Moodle makes extensive use of slash arguments in PHP, causing many
urls to look like this:
/home/[user]/public_html/theme/image.php/standard/theme/1377637305/favicon
I am running this Nginx configuration:
server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
root /usr/share/nginx/www;
index index.html index.htm index.php;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
deny all;
}
location ~ ^/~(?<userdir_user>.+?)(?<userdir_uri>/.*)?$ {
alias /home/$userdir_user/public_html$userdir_uri;
index index.html index.htm index.php;
autoindex off; ## to allow autoindex a la apache
include php5_generic;
}
}
## php5_generic
location ~ \.php {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
The problem I have is that this configuration does work for plain php
files, but not for HTTP GET requests using slash arguments. The Nginx
error log reports that php-fpm raises errors like there:
*615 open()
"/home/[user]/public_html/theme/image.php/standard/core/1377637305/moodlelogo"
failed (20: Not a directory),
or
5 FastCGI sent in stderr: "Access to the script
'/home/[user]/public_html/lib/javascript.php/1377637305/lib/javascript-static.js'
has been denied (see security.limit_extensions)"
What is going wrong here?
No comments:
Post a Comment