Move from Passenger Standalone to Passenger on nginx with Ubuntu 16.04

276 views
Skip to first unread message

nexar

unread,
May 9, 2017, 7:44:23 AM5/9/17
to Phusion Passenger Discussions
I currently have 2 Rails apps (using different Ruby versions) being served by nginx & Passenger Standalone via reverse proxy on my development machine.  One of the apps is now redundant and I thought it might be better to move to the normal Passenger + nginx configuration rather than via Standalone and reverse proxy.

To be on the safe side I then went through the process defined here : 

All of those step give the right results.

I then moved on to the next tutorial here :


Since I already had my app working I simply moved to Step 3 Configuring Passenger and nginx.

The passenger ruby command gave me the following:

passenger_ruby /home/purvez/.rvm/gems/ruby-1.9.3-p0/wrappers/ruby

I then created gi.conf file as described but included some extra stuff to handle some php as well.  I'm attaching that file.

I then restarted nginx.

Within the public directory of gi I have a very simple index.html which simply has an <h1>GI Site</h1>.

Now if I go to gi that index.html gets served up.

However if I go to gi/start where start is a controller within my Rails app then I get a 500.html.

Here are the last few entries from the nginx error.log :


[ 2017-05-09 12:24:34.2104 19165/7f5bbbd8b780 age/Cor/CoreMain.cpp:1055 ]: Passenger core shutdown finished
2017/05/09 12:24:35 [info] 21385#21385: Using 32768KiB of shared memory for nchan in /etc/nginx/nginx.conf:76
[ 2017-05-09 12:24:35.2920 21392/7f5f22208780 age/Wat/WatchdogMain.cpp:1281 ]: Starting Passenger watchdog...
[ 2017-05-09 12:24:35.3014 21395/7fc72c154780 age/Cor/CoreMain.cpp:1070 ]: Starting Passenger core...
[ 2017-05-09 12:24:35.3015 21395/7fc72c154780 age/Cor/CoreMain.cpp:245 ]: Passenger core running in multi-application mode.
[ 2017-05-09 12:24:35.3052 21395/7fc72c154780 age/Cor/CoreMain.cpp:820 ]: Passenger core online, PID 21395
[ 2017-05-09 12:24:35.3151 21405/7f78c0079780 age/Ust/UstRouterMain.cpp:529 ]: Starting Passenger UstRouter...
[ 2017-05-09 12:24:35.3157 21405/7f78c0079780 age/Ust/UstRouterMain.cpp:342 ]: Passenger UstRouter online, PID 21405
[ 2017-05-09 12:24:37.6087 21395/7fc725d78700 age/Cor/SecurityUpdateChecker.h:356 ]: Security update check: no update found (next check in 24 hours)
App 21430 stdout: 
App 21674 stdout: 
App 21430 stderr: cache: [GET /start] miss
App 21430 stderr: cache: [GET /start] miss

12:24 is around when I issued a sudo service nginx restart command.

Here are the relevant entries from the nginx access log:

127.0.0.1 - - [09/May/2017:12:24:08 +0100] "GET /start HTTP/1.1" 502 173 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0"
127.0.0.1 - - [09/May/2017:12:24:09 +0100] "GET /start HTTP/1.1" 502 173 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0"
127.0.0.1 - - [09/May/2017:12:24:43 +0100] "GET /start HTTP/1.1" 500 643 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0"
127.0.0.1 - - [09/May/2017:12:30:49 +0100] "GET /start HTTP/1.1" 500 643 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0"

So it looks like passenger is running but is not serving up my app.

The only other bit of info I have is the following entries within passenger.conf.

passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /usr/bin/passenger_free_ruby;

Please can someone tell me what I'm doing wrong here.

All advice gratefully received with thanks.





gi

Camden Narzt

unread,
May 9, 2017, 10:12:39 AM5/9/17
to Phusion Passenger Discussions
Is there an index.html in your public dir? Passenger defers to nginx serving static files in order to increase the speed for those files. Passenger in Nginx mode defaults to production mode, you might want development mode. And lastly look at the logs in the log folder of your app, there might be something more detailed there.

nexar

unread,
May 9, 2017, 10:31:31 AM5/9/17
to Phusion Passenger Discussions
Hi Camden

Yes there is an index.html in my public directory.  That get's served up correctly.  However only when I try and access my app via gi/start (where start is a controller in Rails) that it falls down.  What should I do to enable development mode, although I can't see how that will make a difference.  Currently looking at the evidence, passenger is not serving my app.  If I was getting a 404 error then I'd be inclined to think that nginx is trying to serve up gi/start.html or something.  However this is a 500 error which makes me think that nginx is getting in touch with passenger but then passenger can't serve up the app.  

I've looked at the logs in the app folder.  Nothing seems to be updating them....hence my thinking that passenger doesn't get near the app.

Camden Narzt

unread,
May 9, 2017, 5:47:13 PM5/9/17
to Phusion Passenger Discussions
Use passenger_app_env: https://www.phusionpassenger.com/library/config/nginx/reference/#passenger_app_env to enable development mode. If you still don't think the requests are hitting your app turn the log up to level 7 to have more details available about what requests Passenger receives.

nexar

unread,
May 10, 2017, 4:40:46 AM5/10/17
to Phusion Passenger Discussions
Hi Camden

Setting the environment to development did the trick.  Although I'm happy that it's working now, I would like to understand why passenger is affected by whether the environment is development or production.  I would have expected that it was RAILS that cared and all passenger did was serve up the app.

Just to double check I removed the environment variable and the problem returned.  Any light you can shed would be very useful in increasing my understanding.  

I'm marking this as completed.

Many thanks for all your help here.

Camden Narzt

unread,
May 10, 2017, 7:55:23 AM5/10/17
to Phusion Passenger Discussions
There is more to be done when setting your app to production mode than just switching an environment variable, you have to create and populate a production DB, precompile the static assets, ensure all the secrets are provided by environment variables and possibly more. It's fairly normal to get a 500 from your app if you haven't done those things. In this case Passenger was forwarding the request to your app, it was just a case where your app wasn't able to complete the response because it wasn't setup fully for production.

nexar

unread,
May 10, 2017, 12:59:28 PM5/10/17
to Phusion Passenger Discussions
This is my development machine so the app is in development mode.  However I thought the RAILS_ENV variable within the app is what controlled what and how things were served up.  The RAILS_ENV variable inside the app is correctly set to development.....hence it would have supplied every to passenger from that environment.  This behaviour somehow seems to suggest that passenger itself is trying to control the app's environment in some way.
Reply all
Reply to author
Forward
0 new messages