Showing posts with label nginx. Show all posts
Showing posts with label nginx. Show all posts

2009/01/23

502 Bad Gateway



Recently, I've changed my server from mod-passenger to nginx because of the comment at merb google groups[link]. Passenger was fit for me. It makes deployment more easier than before. However, merb's way of handling processes seems complicated and advanced as Ezra said[link]. And it is not fully compatible with passenger now.

So I came back to nginx. I thought it would be easy. But it took some time to run my small app. I 've seen a lot of "502 Bad Gateway" page. I guessed that compiling was wrong at first time. It wasn't nginx but my logic in the codes. So the best way to check what's wrong, just type "merb" on the server. I haven't installed necessary gems and libraries. Yes, it is very basic stuff but easy to miss.

2008/01/16

Gusty, Nginx, Rails and Mongrel_cluster howto

Here are the articles where I learned proper way to do this.

sudo cp /usr/lib/ruby/gems/1.8/gems/mongrel_cluster-1.0.5/resources/mongrel_cluster /etc/init.d/mongrel_cluster

Next, add a path statement to mongrel_cluster file just above the CONF_DIR variable:
sudo vi /etc/init.d/mongrel_cluster

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local:/usr/local/sbin:/usr/local/bin
USER=mongrel to USER=www-data

sudo chmod +x /etc/init.d/mongrel_cluster
sudo update-rc.d mongrel_cluster defaults

In our rails app directory we need to create our mongrel config and then symlink it to where our mongrel config directory located at /etc/mongrel_cluster.

nano config/mongrel_cluster.yml

cwd: /var/www/rails/coredrill
log_file: log/mongrel.log
port: 8000
environment: production
group: www-data
user: mongrel
address: 127.0.0.1
pid_file: tmp/pids/mongrel.pid
servers: 3


ln -s /var/www/rails/coredrill/config/mongrel_cluster.yaml /etc/mongrel_cluster/coredrill.yaml

Starting nginx: 2008/01/15 23:17:19 [warn] 3238#0: conflicting server
name "coredrill.wowdns.com" on 37.208.125.80:80, ignored
==>
You have to add this to your default vhost:

server_name _ *;
listen 8080 default;


Finally, check your vhost config.
server
 listen 37.208.125.80:80; => listen 8080;
...
}
sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default



mongrel_rails start -d -e production -p 8000 -P log/mongrel8000.pid 
mongrel_rails start -d -e production -p 8001 -P log/mongrel8001.pid 
mongrel_rails cluster::start 
mongrel_cluster_ctl status