Running faye server with nginx and passenger? - ruby-on-rails

I have successfully installed number of rails applications with nginx and passenger, but with a faye application i don't know what should be:
Nginx conf for a faye application, A nice self-explanatory tutorial will suffice.
List of things that I need to have installed to run faye server
Is it mandatory to open 443(https) port for the server and is port 9292 not needed?
Do i run faye server from rackup command in a screen or not? If no, what root do i set in nginx conf for nginx to know the start point?
How does thin server come into play? Is it needed to run?
I followed this tutorial to make my faye app. So far I have been using it through heroku, but due to latency issues I have to move to a server in the local region
Here's an example to a deployed faye app .
So far I have faye app, passenger and nginx installed on the server(centos). I am just looking for answers to above questions to proceed further. Please help Thanks in advance

Related

Setting up multiple rails apps using nginx and Puma

I have a web server serving multiple Rails applications using a combination of nginx and Passenger. This is pretty straightforward, because the Passenger install sets-up pretty much everything you need to connect to nginx.
I found "Rails app with Puma" that seems to explain how to set up nginx and Puma together. How would this configuration need to be modified in order to serve a second Rails application on the same server?
Also, this guide doesn't say anything about restarting the application automatically if there is a system reboot or some other issue. Is there a way to do that? The nginx + Passenger combo seems to do it by default.

Start Unicorn using ssl in development

I'm migrating my rails app (still in development) from Thin to Unicorn. My app uses config.force_ssl = true.
When using Thin I could just write:
thin start --ssl
My question is: What is the equivalent way to start Unicorn with ssl in development?
If I correctly understood your question, you're trying to run unicorn on port 443.
This is a bad idea.
Instead, to achieve the same goal, I would suggest, run unicorn on an unprivileged port (above 1024), or better on a unix socket, and switch Nginx before, passing all static stuff directly trough nginx, and the rails stuff, trough unicorn.
I know this doesn't answer your question, but for the user, it will work exactly the same, with some benefits when your app server (unicorn) crashes, for example a nice rendered 502 error page served via nginx instead of a plain network error message seen in the browser of your users.
You can with this solution run X different applications on the same port, with different subdomains. a must have for a development machine with many projects.

Deploying Rails applications with Passenger and Nginx to VPS (EC2)

I've developed a couple of applications which I'm ready to deploy. To do so, I've configured Capistrano and I'm already able to run cap deploy, which runs properly. However, I'm totally lost as to how to continue from here. My setup is EC2 + Rails 3.2 + Ruby 1.9.3 + Passenger + Nginx (the one Passenger installs first time you try to start it) + Capistrano.
Until now, I just ran passenger start on my app root folder, which would start passenger on port 3000, and I would start the second app on port 3001. Now, what I need is to have this 2 apps under 2 different domains, say www.domain1.com and www.domain2.com.
How am I supposed to start the servers now? I can go to the respective current folders that Capistrano created and run something like passenger start -e production -p 3001 -d and it starts running as a daemon, but, shouldn't capistrano take care of this? All I see is that, on each deploy, it touches the restart.txt file and that forces a "soft restart", which is not enough (as far as I know) if you've changed gems. Shouldn't Capistrano be starting and stopping Passenger, not me?
How do I run the 2 apps on 2 domains? As far as I know, you can't point a domain to a port, and all I've managed to do now is to run 1 of the applications by running Passenger on port 80 with rvmsudo, but of course this only works for 1 application. After searching a bit I've found something about Nginx Virtual Servers. How do you do this? I mean, I have never touched anything specific to Nginx, just Passenger! Am I supposed to forget about Passenger and deal with Nginx as a service? How?
Thanks in advance!
I believe to start servers there's a specific cap command to start servers, but i don't know much about capistrano, just played with it a little bit before.
As for the second part, this is where nginx takes part, nginx will handle forwarding each domain to the specific port, using proxy_pass, take a look at this example
server {
server_name: example1.com;
proxy_pass: http://127.0.0.1:3000;
}
server {
server_name: example2.com;
proxy_pass: http://127.0.0.1:3001;
}

Starting Rails server on boot on CentOS

I'm pretty new to rails and trying to figure things out, I looked online but not much luck.
I have some servers that are running rails on startup without using rc.local at all, but I can't figure out why.
All I need is for rails to start on boot in production mode on port 80 (instead of 3000, as the rest of the servers also start on port 80).
Any ideas?
ATM relaying on webrick
Have a look at setting up nginx with ruby enterprise edition.
Check out Phusion Passenger. It supports both the standard Apache web server and Nginx web server.
http://www.modrails.com/

Rails framework & Nginx web server

As we install rails it uses its own web server WEBrick. If i want to run ths application in Nginx server, then how to configure or set the Nginx web werver?
You should run your rails application in a production server such as mongrel_cluster or thin (I have used the former, and am currently switching to the latter). To put nginx in front of it, I would use the upstream and proxy_pass directives. I found a nice blog post comparing ways of running rails applications that shows their config for mongrel_cluster + nginx.
Passenger is also available for nginx, I've used that with Apache and it was very easy to set up.

Resources