Wednesday, 15 February 2012

ruby - Running Multiple Rails Apps on Single Nginx with Subdomains -



ruby - Running Multiple Rails Apps on Single Nginx with Subdomains -

i'm trying figure out how 2nd rails app running on server under subdomain. here's setup:

(app1) primary rails app -> http://humani.se

(app2) secondary rails app -> http://supportme.humani.se

the domain name purchased through godaddy, , have subdomain pointing http://humani.se:3000 (through godaddy panel), can see works visiting url. know, know -- app1 running in production , app2 running in development, not practice. i'm trying see if can working.

nginx conf:

# primary application server upstream humanise { # unix domain socket setups: server unix:/home/jeff/srv/humani.se/tmp/sockets/unicorn.sock fail_timeout=0; # server localhost:8080; } server { server_name humani.se www.humani.se; # path static files root /home/jeff/srv/humani.se/public; try_files $uri/index.html $uri.html $uri @humanise; location @humanise { proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header host $http_host; proxy_redirect off; # proxy_pass http://unix:/home/jeff/srv/humani.se/tmp/sockets/unicorn.sock; proxy_pass http://humanise; } error_page 500 502 503 504 /500.html; client_max_body_size 4g; keepalive_timeout 10; } # secondary application server upstream supportme { server localhost:3000; } server { server_name supportme.humani.se; try_files $uri/index.html $uri @supportme; location @supportme { proxy_pass http://supportme; proxy_set_header host $host; proxy_buffering off; } error_page 500 502 503 504 /500.html; client_max_body_size 4g; keepalive_timeout 10; }

looks works, right? nope! routes seem work except rails side. if effort login (with any/no credentials), see error, too. basically, url helpers aren't working controller side. ones in views (anchor hyperlinks) work fine. server log:

started post "/login" 127.0.0.1 @ 2014-06-20 13:51:56 -0400 processing userscontroller#login html parameters: {"utf8"=>"✓", "authenticity_token"=>"ejvcm5auwcwfzw2bry8dlzv8w5i3z0w529mxajrljb0=", "user"=>{"email"=>"ijt", "password"=>"[filtered]"}, "commit"=>"sign in"} user load (0.5ms) select `users`.* `users` `users`.`email` = 'ijt' limit 1 redirected http://supportme.humani.se/ completed 302 found in 4ms (activerecord: 0.5ms) started "/.humani.se/" 127.0.0.1 @ 2014-06-20 13:51:56 -0400 actioncontroller::routingerror (no route matches [get] "/.humani.se"): actionpack (4.0.4) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' actionpack (4.0.4) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' railties (4.0.4) lib/rails/rack/logger.rb:38:in `call_app' railties (4.0.4) lib/rails/rack/logger.rb:20:in `block in call' activesupport (4.0.4) lib/active_support/tagged_logging.rb:68:in `block in tagged' activesupport (4.0.4) lib/active_support/tagged_logging.rb:26:in `tagged' activesupport (4.0.4) lib/active_support/tagged_logging.rb:68:in `tagged' railties (4.0.4) lib/rails/rack/logger.rb:20:in `call' actionpack (4.0.4) lib/action_dispatch/middleware/request_id.rb:21:in `call' rack (1.5.2) lib/rack/methodoverride.rb:21:in `call' rack (1.5.2) lib/rack/runtime.rb:17:in `call' activesupport (4.0.4) lib/active_support/cache/strategy/local_cache.rb:83:in `call' rack (1.5.2) lib/rack/lock.rb:17:in `call' actionpack (4.0.4) lib/action_dispatch/middleware/static.rb:64:in `call' rack (1.5.2) lib/rack/sendfile.rb:112:in `call' railties (4.0.4) lib/rails/engine.rb:511:in `call' railties (4.0.4) lib/rails/application.rb:97:in `call' rack (1.5.2) lib/rack/lock.rb:17:in `call' rack (1.5.2) lib/rack/content_length.rb:14:in `call' rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service' /home/jeff/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service' /home/jeff/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run' /home/jeff/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'

you can see it's redirecting right url gets /.humani.se/ instead. somewhere must know this!

any , help appreciated!

thanks in advance, - jeff

first of should not allow godaddy point port, point both humani.se , supportme.humani.se same ip, , allow nginx redirect each right app, can run app1 on port 3000 , app2 on port 3001 proxy on nginx

server { server_name humani.se; location / { proxy_pass http://localhost:3000; } } server { server_name support.humani.se; location / { proxy_pass http://localhost:3001; } }

this should trick, tell me get.

ruby-on-rails ruby nginx subdomain

No comments:

Post a Comment