Reputation: 133
I need to set some server specific variables in a rails application that will run on at least two different servers. What is the best way to get the request's HTTP_HOST value in order to know what is the current server and set these variables accordingly? I'm using Apache 2 with Passenger.
Upvotes: 4
Views: 5389
Reputation: 5416
Are the 2 servers involved in load balancing? If so, you won't want to grab the host from the request, because it'll be the same in both cases. You'll want to grab it in some generic ruby call. It's been a while since I've done Ruby, but probably something like (untested - rough idea):
Resolv::Hosts.getNames(Resolv::Hosts.getAddress('localhost'))
Upvotes: 0