boxen/our-boxen — pull request #359 by createdbypete (2013-07-16 10:48:56+00:00)
Title: Support for xip.io

Regex based Nginx server_name matches app name and any subdomain for the [xip.io](http://xip.io) service. Provides some consistency with the popular Pow application server features (for those like me that have moved away) and obviously the benefit of network access to the application from another machine.

One small gotcha that I have noticed and I'm not sure if there is a work around, within a Rails application if you are using subdomains locally for your application (foo.bar.dev for example) you will need to update the `action_dispatch.tld_length` to `6` (assuming no more periods(.) in your application name) I think in your `config/environments/development.rb` file so Rails can isolate the right part of the hostname.

I explored using the code below in the location block but this messes up some redirects within the application as it sees the `.dev` hostname that the remote machine cannot resolve correctly. Hence the suggestion above works as a temporary fix but I wonder if there is someway to make it a more permanent solution? My experience with subdomains in Rails is limited.

```nginx
set $real_host $host;
# strip '.1.2.3.4.xip.io' from the host
if ($real_host ~ '(.*)(\.\d+){4}\.xip\.io$') {
set $real_host $1.dev;
}
# pass the modified host to the app
proxy_set_header Host $real_host;
```