Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have set up nginx (nginx.conf below) and thin. Both nginx and thin (2 servers) are running (I have checked they are running). I can access a static page in the rails public directory such as index.html but if I put in any other url I get a 500 page generated by nginx saying 'We're sorry, but something went wrong.' Any help on what I am doing wrong is appreciated. I want to be able to access the rails application.

http {
include   /etc/nginx/mime.types;
default_type  application/octet-stream;

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout 30;

#gzip  on;

# Load config files from the /etc/nginx/conf.d directory
# The default server is in conf.d/default.conf
include /etc/nginx/conf.d/*.conf;

#Rails app config here
upstream Backend  {

server {
       listen   80;
       rewrite ^/(.*) permanent;

server {
        listen   80;

        access_log /applications/RailsApp/log/access.log;
        error_log /applications/RailsApp/log/error.log;

        root /applications/RailsApp/public;
        # index  index.html;

        location / {
                      proxy_set_header  X-Real-IP  $remote_addr;
                      proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
                      proxy_set_header Host $http_host;
                      proxy_redirect off;

                      if (-f $request_filename/index.html) {
                                       rewrite (.*) $1/index.html break;

                      if (-f $request_filename.html) {
                                       rewrite (.*) $1.html break;

                      if (!-f $request_filename) {
                                       proxy_pass http://Backend;



This exactly my nginx.conf except for here is a placeholder for the actual domain.

share|improve this question
What does nginx's error.log contain? I've never seen such a message from nginx though, so I'd suspect that the 500 response is from Rails, not nginx. – mgorven May 21 '12 at 0:26
You may be correct, the nginx error log does not contain any recent errors. – Skill M2 May 21 '12 at 1:24

After realizing that the error was from rails and not nginx or thin the issue was resolved fairly quickly by checking log/production.log in my Rails application. I had two problems.

First the socket for my production db in config/database.yml was incorrect. I had to change it from the incorrect socket: tmp/mysql.sock to where it actually is on my system, socket: var/lib/mysql/mysql.sock.

After this there was another error in log/production.log about a css file not being precompiled. This was fixed by editing config/environments/production.rb and changing 'config.assets.compile = false' to 'config.assets.compile = true'.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.