25

Nginx does not follow symbolic links. I get a 404 error. In my directory, I have this link:

lrwxrwxrwx  1 root root    48 Sep 23 08:52 modules -> /path/to/dir/

but the files stored in /path/to/dir aren't found.

  • Have a look at nginx.org/en/docs/http/… – Andy Sep 23 '14 at 9:54
  • 1
    OK i resolved with disable_symlinks off;. Thanks! – hellb0y77 Sep 23 '14 at 11:08
  • No problem.Have a nice day! – Andy Sep 23 '14 at 11:09
  • Please either type your solution as an answer and accept it (it's fair behaviour here) or elsewhere delete your question. – leonbloy Sep 23 '14 at 11:19
  • Any other ideas? I'm having this problem, I tried putting disable_symlinks off; in my conf (even though that is actually the default anyways) and nothing is working. – user112667 May 1 '15 at 0:43
33

I insert disable_symlinks off; in my nginx.conf and i resolved, works fine!

http {
    disable_symlinks off;
}
  • I got nginx: [emerg] unknown directive "disable_symlinks" in /usr/local/etc/nginx/nginx.conf:22 after doing this. I was using nginx/1.8.0 on Mac OS X. – frozen-flame Dec 10 '15 at 9:17
  • 2
    @frozen-flame disable_symlinks was added in version 1.1.15 (see docs), so it should have worked. Are you sure you were on 1.8.0, and that it was in the allowed context (http, server, or location)? – Ville May 7 '16 at 1:47
  • 1
    Context to use disable_symlinks: http, server, location – Thiago Pereira Apr 4 at 16:56
1

I found the solution on this post.

More specifically, these lines:

fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
1

Use 'bind' option by mounting folders =)

sudo nano /etc/fstab

Type:

/path/where/my/big/files_dir /var/www/myhost/media_dir bind defaults,bind 0 0

(no symlinks & don't forget restart vds/cpu)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.