[英]Nginx not detecting the root location from config for Rails 3.2 app
这是在ubuntu 12.04上运行的nginx服务器的error.log。
2014/03/17 12:47:17 [error] 7939#0: *1 open() "/opt/nginx/html/mkl/authentify/signin" failed (2: No such file or directory), client: xxx.xxx.228.66, server: xxx.xxx.109.181, request: "GET /mkl/authentify/signin HTTP/1.1", host: "xxx.xxx.109.181"
在/opt/nginx/conf/nginx.conf中,它配置如下(conf中唯一的服务器块):
server {
listen 80;
server_name xxx.xxx.109.181;
root /ebs/www/;
passenger_enabled on;
rails_env production;
passenger_base_uri /mkl;
.....
}
nginx服务器的根目录是/ ebs / www /。 但是nginx正在访问/ opt / nginx并且没有抛出这样的文件错误。 是什么原因造成的? 谢谢。
在安装gem passenger
后, nginx
安装了passenger-install-nginx-module
。
正确的root是您的应用程序中的公共订单:
server {
listen 80;
server_name xxx.xxx.109.181;
root /ebs/www/YOUR_APPLICATION/current/public;
# e.g. root /var/www/vhosts/example.com/httpdocs/example/current/public;
passenger_enabled on;
rails_env production;
passenger_base_uri /mkl;
.....
}
在nginx.conf中的第一个(唯一)服务器块之后再添加一个server {}块后,问题得以解决。 在以前的版本(可能是1.4.x)中,nginx.conf中有2个服务器块。 在当前版本中,只有一个服务器{}块。
有关该解决方案的更多信息,请参阅为什么nginx会响应任何域名? & https://serverfault.com/questions/416064/rails-application-only-showing-nginx-default-page
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.