how to Handle Subdomain in rails with unicorn, and nginx -


i followed simple railscasts episode on multitenant tenants in app enters subdomain works locally on dev syatem wen try same process on vps system, browser says cannot find server.

i have connected domain ip , modified nginx file , still no hope

once user enters subdomain, request not rails app.

any idea on or might not getting right.

my nginx_unicorn_file

upstream unicorn {   server unix:/tmp/unicorn.<%= application %>.sock fail_timeout=0; }  server {   listen 80 default deferred;   server_name shopnany.com *.shopnany.com;   root <%= current_path %>/public;    location ^~ /assets/ {     gzip_static on;     expires max;     add_header cache-control public;   }    try_files $uri/index.html $uri @unicorn;   location @unicorn {     proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;     proxy_set_header host $http_host;     proxy_redirect off;     proxy_pass http://unicorn;   }    error_page 500 502 503 504 /500.html;   client_max_body_size 4g;   keepalive_timeout 10; } 

i had no problem doing this. first need create record in dns provider using. example create dns record:

it.shopnany.com

then you'll have update nginx config template particular deployment. can follows:

upstream unicorn_<%= application %> {   server unix:/tmp/unicorn.<%= application %>.sock fail_timeout=0; }  server {   listen 80;   server_name it.shopnany.com;   root <%= current_path %>/public;    location ~ ^/assets/ {     gzip_static on;     expires max;     add_header cache-control public;   }    try_files $uri/index.html $uri @unicorn;   location @unicorn {     proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;     proxy_set_header host $http_host;     proxy_redirect off;     proxy_pass http://unicorn_<%= application %>;   }    error_page 500 502 503 504 /500.html;   client_max_body_size 4g;   keepalive_timeout 10; } 

this worked me. have 2 different applications running on www , subdomains.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -