Nginx / Ruby / Rails

Nginxでサーバ設定。

server {
  listen 80;
  server_name localhost;
  root /path/to/project/public;

  location / {
    if ( -f $request_filename ) { break; }
    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_pass http://localhost:8080;
  }

  location ~* \.(ico|css|js|gif|jpe?g|png|woff|ttf|svg)(\?[0-9]+)?$ {
    expires 1y;
  }
}

RailsをProduction環境で起動

$ rails s -e production -p 8080

http://localhost/ から確認できます。