Can my /public directory be a symlink with rails 3 + passenger 3 + nginx 0.8?

I'm putting together a rails deployment where the public directory is a symlink to another directory on the system. This is with passenger 3 on nginx .8. It does't seem to like that setup. Nginx always follows symlinks by default, so AFAIK it's not a matter of doing the equivalent of Apache's +FollowSymLinks.

update

Looks like this is covered here: http://www.modrails.com/documentation/Users%20guide%20Nginx.html#application_detection

Note that Phusion Passenger for Nginx does not resolve any symlinks in the root path. So for example, suppose that your root points to /home/www/example.com, which in turn is a symlink to /webapps/example.com/public. Phusion Passenger for Nginx will check for /home/www/config/environment.rb, not /webapps/example.com/config/environment.rb. This file of course doesn't exist, and as a result Phusion Passenger will not activate itself for this virtual host, and you'll most likely see some output generated by the Nginx default directory handler such as a Forbidden error message.

Detection of Rack applications happens through the same mechanism, exception that Phusion Passenger will look for config.ru instead of config/environment.rb.

So I wonder if some proper symlinking of config.ru might do the trick.


I think it is not possible to use a symlinked public directory. The only workaround I can imagine is to symlink any file and directory inside of the public dir.

# public folder: /data/public
# app folder: /webapp/
mkdir -p /webapp/public && ln -sf /data/public/* /webapp/public/

For every new file or directory in /data/public you have to run this command again.


Can't you use the following:

mount --bind /original_path /your_ngnix_root_path

instead of using symlinks? For ngnix it would be a usual directory, why it will point to another directory as you wanted it to be.

链接地址: http://www.djcxy.com/p/5552.html

上一篇: Nginx 403禁止所有文件

下一篇: 我的/公共目录是一个符号链接3 +乘客3 + nginx 0.8?