I'm using sub-domains within my Padrino configuration. I've created multiple A records in AWS Route 53 to route to things like api.myapp.com & admin.myapp.com, myapp.com, www.myapp.com. This is working as expected. Here's what my configuration looks like:
Padrino.mount('MyApp::App', :app_file => Padrino.root('app/app.rb')).host('api.myapp.com')
Padrino.mount('MyApp::Manager', :app_file => Padrino.root('manager/app.rb')).host('manager.myapp.com')
Padrino.mount("MyApp::Admin", :app_file => File.expand_path('../../admin/app.rb', __FILE__)).host("admin.myapp.com")
Padrino.mount('MyApp::Web', :app_file => Padrino.root('web/app.rb')).to('/')
I've replaced the real name to "myapp" for the purpose of this question. The problem is when I attempt to access these sub-domains on my localhost. It keeps routing to web/app.rb (which is at just '/'). I tried altering my /etc/hosts
as so:
127.0.0.1 localhost
127.0.0.1 manager.myapp.com
127.0.0.1 api.myapp.com
127.0.0.1 admin.myapp.com
Then when I try to hit manager.myapp.com:3000
, it routes to what's being served as the root domain (MyApp::Web). Why is this happening?
I made some configuration changes in config/apps.rb
to use a particular subdomain on whether or not it's deployed or running locally. Then I updated my /etc/hosts
with the following values:
127.0.0.1 manager.localhost manager
127.0.0.1 api.localhost api
127.0.0.1 admin.localhost admin
This doesn't really mean anything though. The problem was that I was running on port 3000, which these values don't account for. Since I'm through fighting with /etc/hosts
(and would love some guidance), I just ran my local server on port 80 and all worked OK.