使 Nginx 遵循符号链接

hel*_*y77 37 symlink nginx

Nginx 不遵循符号链接。我收到 404 错误。在我的目录中,我有这个链接:

lrwxrwxrwx  1 root root    48 Sep 23 08:52 modules -> /path/to/dir/
Run Code Online (Sandbox Code Playgroud)

但是/path/to/dir找不到存储在其中的文件。

hel*_*y77 53

我插入disable_symlinks off;我的 nginx.conf 并解决了,工作正常!

http {
    disable_symlinks off;
}
Run Code Online (Sandbox Code Playgroud)

  • @frozen-flame `disable_symlinks` 是在 1.1.15 版中添加的([参见文档](http://nginx.org/en/docs/http/ngx_http_core_module.html#disable_symlinks)),所以它应该有效。您确定您使用的是 1.8.0,并且它在允许的上下文中(http、服务器或位置)? (2认同)
  • 使用 `disable_symlinks` 的上下文:`http, server, location` (2认同)

小智 6

通过安装文件夹使用“绑定”选项 =)

sudo nano /etc/fstab
Run Code Online (Sandbox Code Playgroud)

类型:

/path/where/my/big/files_dir /var/www/myhost/media_dir bind defaults,bind 0 0
Run Code Online (Sandbox Code Playgroud)

(没有符号链接并且不要忘记重新启动 vds/cpu)