简体   繁体   中英

Nginx not detecting the root location from config for Rails 3.2 app

Here is the error.log of nginx server running on ubuntu 12.04.

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"

In /opt/nginx/conf/nginx.conf, it is configured as following (the only server block in conf):

  server {
    listen 80;
    server_name xxx.xxx.109.181;
    root /ebs/www/;
    passenger_enabled on;
    rails_env production;
    passenger_base_uri /mkl;
    .....
  }

The root of nginx server is pointing to /ebs/www/. However the nginx is accessing the /opt/nginx and throws out no such file error. What causes the problem? Thanks.

The nginx was installed with passenger-install-nginx-module after gem passenger was installed.

Correctly root is your public order from your application:

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;
  .....
}

The problem is fixed after adding one more server {} block after the first (only) server block in nginx.conf. In previous version (probably 1.4.x), there were 2 server blocks in nginx.conf. In current version, there is only one server {} block.

More reading about the solution can be found at Why is nginx responding to any domain name? & https://serverfault.com/questions/416064/rails-application-only-showing-nginx-default-page

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM