1

We noticed this error when users filled up forms on our Drupal site, attached an image and saved it. To identify the root cause (I expected it to be an ownership or a directory permission issue). I recreated the exact folder structure on my laptop. Deployed the site and tried submitting the Form. Had the same issue. The error logs have the following entries

2016/06/29 21:29:28 [error] 9419#0: *13 directory index of "/home/sridhar/public_html/pg4me/public/sites/default/files/" is forbidden, client: 127.0.0.1, server: pg4me, request: "GET /sites/default/files/ HTTP/1.1", host: "pg4me", referrer: "http://pg4me/newproperty" 

I checked the ownership and permissions of the directory structure

namei -l /home/sridhar/public_html/pg4me/public/sites/all/modules/ f: /home/sridhar/public_html/pg4me/public/sites/default/files drwxr-xr-x root root / drwxr-xr-x root root home drwxrwxr-x sridhar sridhar sridhar drwxrwxr-x sridhar sridhar public_html drwxr-xr-x sridhar sridhar pg4me drwxr-xr-x sridhar sridhar public drwxr-xr-x sridhar sridhar sites drwxr-xr-x sridhar sridhar default drwxrwxrwx sridhar sridhar files 

All upline directories have executable permissions and the files directory has read, write and execute (though not very secure had to provide 777 to check if its working). NGINX runs as www-data.

My vhost configuration in /etc/nginx/sites-available has the following entries

server { listen pg4me; server_name pg4me; root /home/sridhar/public_html/pg4me/public; index index.php index.html index.htm; keepalive_timeout 70; access_log /home/sridhar/public_html/pg4me/log/access.log; error_log /home/sridhar/public_html/pg4me/log/error.log; # Make site accessible from http://localhost/ location / { try_files $uri $uri/ @rewrite; expires max; } location @rewrite { rewrite ^ /index.php; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } } 

Since the error message was indicating a directory listing error I included the following to my vhost nginx configuration

location /home/sridhar/public_html/pg4me/public/sites/default/files/ { autoindex on; } 

But it had no effect. Having come to my wits end I tried the stack trace

root@sridhar-Aspire-5745:/home/sridhar/public_html# strace -p 9419 -p 9420 -p 9421 -p 9422 -e trace=file -f Process 9419 attached Process 9420 attached Process 9421 attached Process 9422 attached [pid 9419] stat64("/home/sridhar/public_html/pg4me/public/newproperty", 0xbfc6c110) = -1 ENOENT (No such file or directory) [pid 9419] stat64("/home/sridhar/public_html/pg4me/public/newproperty", 0xbfc6c110) = -1 ENOENT (No such file or directory) [pid 9419] stat64("/home/sridhar/public_html/pg4me/public/sites/default/files/", {st_mode=S_IFDIR|0777, st_size=69632, ...}) = 0 [pid 9419] stat64("/home/sridhar/public_html/pg4me/public/sites/default/files/", {st_mode=S_IFDIR|0777, st_size=69632, ...}) = 0 [pid 9419] stat64("/home/sridhar/public_html/pg4me/public/sites/default/files/index.php", 0xbfc6c090) = -1 ENOENT (No such file or directory) [pid 9419] stat64("/home/sridhar/public_html/pg4me/public/sites/default/files", {st_mode=S_IFDIR|0777, st_size=69632, ...}) = 0 [pid 9419] stat64("/home/sridhar/public_html/pg4me/public/sites/default/files/index.html", 0xbfc6c090) = -1 ENOENT (No such file or directory) [pid 9419] stat64("/home/sridhar/public_html/pg4me/public/sites/default/files/index.htm", 0xbfc6c090) = -1 ENOENT (No such file or directory) 

I have no clue why NGINX is looking for index.php in the sites/default/files/ . I checked my module code and couldn't find any references to index files in the sites/default/files directory.

Wondering what could be the cause of this rather strange behaviour

2
  • That should be location /sites/default/files/ { autoindex on; } Commented Jun 29, 2016 at 20:57
  • Changed as suggested. Issue still persists. Commented Jun 30, 2016 at 3:33

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.