Jarrod Menoube
2007-Sep-18 17:06 UTC
Nginx-Mongrel almost working; just need a little help
Hello Rails experts. I''m trying to set up Nginx with Mongrel cluster
for
my Rails app. I got Nginx and Mongrel cluster to each work. I got Nginx
to serve static files no problem. It displays the Rails intro page, for
example.
And I got Mongrel cluster to run, and when I check each of the nodes
individually it is serving the dynamic Rails pages as expected.
However, when I start them both and then try to access my app, I get the
error "Bad Gateway".
In the Nginx error log I find each attempt produces three entries like
this...
1. 2007/09/18 06:53:13 [error] 156690: *1 connect() failed (111:
Connection refused) while reading response header from upstream, client:
24.143.132.67, server: www.joehost.com, URL: "/journal", upstream:
"http://127.0.0.1:3000/journal", host: "joehost.com"
2. 2007/09/18 06:53:13 [error] 156690: *1 connect() failed (111:
Connection refused) while reading response header from upstream, client:
24.143.132.67, server: www.joehost.com, URL: "/journal", upstream:
"http://127.0.0.1:3001/journal", host: "joehost.com"
3. 2007/09/18 06:53:13 [error] 156690: *1 connect() failed (111:
Connection refused) while reading response header from upstream, client:
24.143.132.67, server: www.joehost.com, URL: "/journal", upstream:
"http://127.0.0.1:3002/journal", host: "joehost.com"
My Nginx config file contains...
upstream mongrel {
server 127.0.0.1:3000;
server 127.0.0.1:3001;
server 127.0.0.1:3002;
}
server {
listen 80;
client_max_body_size 1M;
server_name joehost.com;
root /home/joe/www/public;
access_log logs/nginx.joe.access.log main;
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html last;
break;
}
location / {
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_redirect false;
proxy_max_temp_file_size 0;
if (-f $request_filename) {
break;
}
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
if (!-f $request_filename) {
proxy_pass http://mongrel;
break;
}
}
Any help would be greatly appreciated.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
your config looks copy right off from http://brainspl.at/nginx.conf.txt
, seems fine.
try "server_name joehost.com www.joehost.com"
there''s also a nginx config generator
"gem install nginx_config_generator"
below is mine,
upstream groups {
ip_hash;
server localhost:3000;
server localhost:3001;
}
server {
listen 80;
server_name groups.wuyasea.com;
access_log /u/apps/groups/current/log/access_log
main;
error_log /u/apps/groups/current/log/error_log
info;
root /u/apps/groups/current/public;
location / {
# needed to forward user''s IP address to rails
proxy_set_header X-Real-IP $remote_addr;
# needed for HTTPS
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect false;
proxy_max_temp_file_size 0;
if (!-f $request_filename) {
proxy_pass http://groups;
break;
}
}
}
Dorren
http://groups.wuyasea.com/group/nginx
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Jarrod Menoube
2007-Sep-18 18:45 UTC
Re: Nginx-Mongrel almost working; just need a little help
Dorren wrote:> your config looks copy right off from http://brainspl.at/nginx.conf.txt > , seems fine.Thanks for the reply. Yes, it''s adapted from that config file. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---