Nginx, Rails, and Unicorn - 404 File not Found

BalinKingOfMoria Reinstate CMs

Whenever I try to access the Rails app, I get the default Nginx 404 page and the following error in /var/log/nginx/error.log:

2015/11/16 21:45:30 [error] 16240#0: *78 open() "/usr/local/apps/careers_api/current/public/application/test_aggregate.json" failed (2: No such file or directory), client: 70.184.87.69, server: careers-api.dynamynd.com, request: "GET /application/test_aggregate.json HTTP/1.1", host: "careers-api.dynamynd.com"

nginx.conf:

upstream api_server {
    server unix:/run/unicorn/unicorn-api.sock fail_timeout=0;
}

server {
    listen 443 ssl;

    server_name  abc.xyz.com;
    root /usr/local/apps/abc_xyz/current/public;

    ssl on;
    ssl_certificate /etc/ssl/certs/ssl-bundle.crt;
    ssl_certificate_key /etc/ssl/private/STAR_xyz_com.key;
    ssl_prefer_server_ciphers on;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4;

    location @app {
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_redirect off;
        proxy_pass http://api_server;
    }
}

I have pretty much the same configuration on other apps running on the same machine, and they work just fine.

Richard Smith

location @app is a named location. It can only be invoked indirectly from another location block. You have an implicit location / block, but that contains no command to invoke the upstream service.

So, unless that file is a local static file, located at /usr/local/apps/abc_xyz/current/public/application/test_aggregate.json, you will get a 404 error.

Perhaps you are missing something like:

location / {
  try_files $uri $uri/ @app;
}

or

try_files $uri @app;

in the server block.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related