Document the fact that a config.ru is needed for Rails 2.3
i have vps centos server with last ree (ruby-enterprise-1.8.7-2012.02), rails 2.3, passenger 4.0.59 and nginx 1.7.10 - work fine, but if i install passenger 5.0.2 passenger i get no files or directory on any request, but in same config in passenger 4.0.59 all fine. How to fix the problem?
[ 2015-03-09 09:06:24.7718 21988/7f5b2d1bc730 agents/Watchdog/Main.cpp:1255 ]: Starting PassengerAgent watchdog...
...
[ 2015-03-09 09:06:24.9725 22015/7f92da275730 agents/HelperAgent/Main.cpp:883 ]: Starting PassengerAgent server...
[ 2015-03-09 09:06:24.9726 22015/7f92da275730 agents/HelperAgent/Main.cpp:232 ]: PassengerAgent server running in multi-application mode.
[ 2015-03-09 09:06:24.9734 22015/7f92da275730 agents/HelperAgent/Main.cpp:637 ]: PassengerAgent server online, PID 22015
[ 2015-03-09 09:06:24.9766 22022/7f69923c0730 agents/LoggingAgent/Main.cpp:431 ]: Starting PassengerAgent logger...
[ 2015-03-09 09:06:24.9770 22022/7f69923c0730 agents/LoggingAgent/Main.cpp:312 ]: PassengerAgent logger online, PID 22022
2015/03/09 09:06:36 [error] 22035#0: *1 directory index of "/var/www/vhosts/termoteks.ru/public/" is forbidden, client: 188.138.118.184, server: www.termoteks.ru, request: "GET / HTTP/1.1", host: "termoteks.ru"
2015/03/09 09:06:46 [error] 22035#0: *2 directory index of "/var/www/vhosts/termoteks.ru/public/" is forbidden, client: 128.73.71.103, server: www.termoteks.ru, request: "GET / HTTP/1.1", host: "termoteks.ru"
2015/03/09 09:07:17 [error] 22035#0: *3 directory index of "/var/www/vhosts/termoteks.ru/public/" is forbidden, client: 76.72.167.90, server: www.termoteks.ru, request: "GET / HTTP/1.1", host: "termoteks.ru"
2015/03/09 09:07:53 [error] 22035#0: *4 directory index of "/var/www/vhosts/termoteks.ru/public/" is forbidden, client: 95.108.129.207, server: www.termoteks.ru, request: "GET / HTTP/1.1", host: "www.termoteks.ru"
2015/03/09 09:08:17 [error] 22035#0: *5 directory index of "/var/www/vhosts/termoteks.ru/public/" is forbidden, client: 85.17.156.76, server: www.termoteks.ru, request: "GET / HTTP/1.1", host: "termoteks.ru"
2015/03/09 09:08:39 [error] 22035#0: *6 open() "/var/www/vhosts/termoteks.ru/public/products/bulletproof-glass" failed (2: No such file or directory), client: 178.127.166.65, server: www.termoteks.ru, request: "GET /products/bulletproof-glass HTTP/1.1", host: "www.termoteks.ru", referrer: "http://www.google.by/url?url=http://www.termoteks.ru/products/bulletproof-glass&rct=j&q=&esrc=s&sa=U&ei=aFT9VP2xFongaLm4gqgK&ved=0CEIQFjAJ&usg=AFQjCNHO7HHvw4xjWDfK5xRpFDuVjXspBw"
2015/03/09 09:09:17 [error] 22035#0: *7 directory index of "/var/www/vhosts/termoteks.ru/public/" is forbidden, client: 46.20.45.18, server: www.termoteks.ru, request: "GET / HTTP/1.1", host: "termoteks.ru"
Could you show your Nginx configuration?
user nobody;
worker_processes auto;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
passenger_root /opt/ruby-enterprise-1.8.7-2012.02/lib/ruby/gems/1.8/gems/passenger-4.0.59;
passenger_ruby /opt/ruby-enterprise-1.8.7-2012.02/bin/ruby;
passenger_max_pool_size 2;
passenger_pool_idle_time 0;
include mime.types;
default_type application/octet-stream;
access_log off;
sendfile on;
tcp_nodelay on;
tcp_nopush on;
keepalive_timeout 5;
keepalive_requests 100;
gzip on;
gzip_min_length 1000;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types text/plain text/xml application/xml application/x-javascript text/javascript text/css text/json;
gzip_vary on;
gzip_disable "msie6";
gzip_comp_level 4;
server {
server_name ~^(?!www\.);
rewrite ^ http://www.$host$request_uri permanent;
}
server {
listen 91.227.68.170:80;
server_name www.termoteks.ru;
rewrite ^/(.*)/$ /$1 permanent;
root /var/www/vhosts/termoteks.ru/public;
passenger_enabled on;
location ~* ^.+\.(jpg|gif|png|ico|pdf|ppt|txt|rtf|js|css|html)$ {
root /var/www/vhosts/termoteks.ru/public;
access_log off;
expires 30d;
}
}
}
Of course I remember correct root passenger after install to 5.0.2
Does your Rails 2.3 app contain a config.ru?
i use radiantcms, search in radiant folder and found config.ru in /opt/ruby-enterprise-1.8.7-2012.02/lib/ruby/gems/1.8/gems/radiant-1.1.3/spec/dummy/config.ru
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Dummy::Application
Meant this file?
No. There should be a /opt/ruby-enterprise-1.8.7-2012.02/lib/ruby/gems/1.8/gems/radiant-1.1.3/config.ru. If it's not there, Passenger will not detect the app as a Ruby app.
You should ask the Radiant author what the correct config.ru should be.
Running into the same problem with an older Rails 2.3.18 app. Note that rails 2.3.18 does not generate a config.ru, so it's unlikely that rails 2.3 project ships with one.
For those that run into the same issue, I've added the following config.ru which works fine:
ENV["RAILS_ENV"] ||= ENV["RACK_ENV"]
# Require your environment file to bootstrap Rails
require ::File.dirname(__FILE__) + '/config/environment'
# Serve static assets from RAILS_ROOT/public directory
# use Rails::Rack::Static
# Dispatch the request
run ActionController::Dispatcher.new
When using passenger standlone with the built-in engine and want to server assets you probably want to enable the Rails::Rack::Static middleware as well (commented above).
Some more info can be found in the old rails guides: http://guides.rubyonrails.org/v2.3.11/rails_on_rack.html#rackup
Running into the same problem with an older Rails 2.3.18 app. Note that rails 2.3.18 does not generate a config.ru, so it's unlikely that rails 2.3 project ships with one.
Really? I always remembered that Rails 2.3 was the first Rails version that was Rack-compliant, and that did generate a config.ru. I should double check later.
I checked by generating a new app with rails foo using rails 2.3.18 on ruby 1.9.3:
rails --version
Rails 2.3.18
ls foo | cat
app
config
db
doc
lib
log
public
Rakefile
README
script
test
tmp
vendor
Spend several hours while trying to figure that. No config.ru in rails 2.3 file, so passenger just do not process urls. I think, at least there should be errors in logs, but there is only silence...
Upgrading our enterprise installation from 1:4.0.59-1~wheezy1 to 1:5.0.4-1~wheezy1 broke all our Rails apps ranging in version from 2.3 to 4.0.13; all Apache VirtualHosts are returning directory indexes. Please advise!
Update: Restarting Apache seems to have helped, but our 2.3 apps are still not loading. Adding a config.ru results in a " Missing the Rails 2.3.18 gem." error being logged, but it is installed.
Downgrading to 1:4.0.59-1~wheezy1 seems to be our best option at this point.
The upgrade notes have been updated to document the fact that a config.ru is required for Rails 2.3 apps.
@FooBarWidget What about Rails 2.3 not detecting its gems, mentioned by @bithive ? It is the issue, preventing me migrating to 5.0.
@ypadlyak Most likely your app is just running as the wrong user. Try double checking that. If that isn't it, double check whether environment variables like GEM_PATH are correct.
@FooBarWidget thanks for response! Actually, I've fixed it by adding Gemfile to my 2.3 legacy project, and it works.
@felixbuenemann Just want to say thank you! Your config.ru and Rails 2.3 information was the key to finally fixing a several hour, very stressful experience!
@FooBarWidget - My old Rails 2.3 app (in the process of upgrading it) did not have a config.ru. Upgraded to Passenger 5.0.2 and it just broke and the only indication of what was wrong was the nginx error logs saying "directory index of "/path/to/app/current/public/" is forbidden".
In my opinion, Passenger should really have a better error message - complain loudly in the nginx error log - or somewhere else obvious - about needing a config.ru / or just work if it's clearly being pointed to a rails app, via an nginx server {} directive with passenger_on, etc - but is missing a config.ru. It shouldn't just not work and complain about something unrelated. Improving the errors / feedback if not configured as expected would save some grey hairs for sure.
That said, thanks for Passenger, it's generally awesome.
@sbecker 5.0.2? Hmm, you should upgrade to the latest Passenger (5.0.24), there have been several major issues as well as security vulnerabilities fixed (most recently in Nginx).
We've also been continuously working on improving failure messages here and there, although this particular one about config.ru was mentioned in the upgrade notes as well as the Passenger Library (and has not yet gotten further love beyond that).
Thank you for the config.ru bit- helped me.