Question

Rails (RoR) app not working

Posted February 23, 2016 2.5k views
Ruby on Rails PostgreSQL

Hello, today I deployed my app in a server, I followed this tutorial( [https://www.digitalocean.com/community/tutorials/how-to-use-the-ruby-on-rails-one-click-application-on-digitalocean](http://) ), went everything OK, but when I access my app by IP I receive the error 500. The software works locally perfectly. How can I know where is the problem?

2 comments
  • Can you post your nginx configuration file? 500s could be your config (passing requests through nginx to the ror app) or it could be your RoR app that is crashing somehow (maybe file permissions, bad configuration etc.)

    If your rails app is logging/outputing erros at all when the requests hit it, that would be helpful to post as well.

  • myappname = My app rsrs

    upstream appserver {
    server unix:/var/run/unicorn.sock failtimeout=0;
    }

    server {
    listen 80;
    root /home/rails/myappname/public;
    server_name _;
    index index.htm index.html;

    location / {
    try_files $uri/index.html $uri.html $uri @app;
    }

    location ~* ^.+.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|p$
    try_files $uri @app;
    }

    location @app {
    proxysetheader X-Forwarded-For $proxyaddxforwardedfor;
    proxysetheader Host $httphost;
    proxy
    redirect off;
    proxypass http://appserver;
    }

    }

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

1 answer

myappname = My app rsrs

upstream appserver {
server unix:/var/run/unicorn.sock fail
timeout=0;
}

server {
listen 80;
root /home/rails/myappname/public;
server_name _;
index index.htm index.html;

location / {
        try_files $uri/index.html $uri.html $uri @app;
}

location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|p$
                try_files $uri @app;
        }

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

}

Submit an Answer