Asherlc
Asherlc

Reputation: 1161

Host is "thin" instead of "www.whateverdomain.com"

I'm running Thin and nginx to serve up my rails app. Everything is working fine, except that the root_url helper method returns "thin" as the domain. So root_url(subdomain: "foo") in a controller returns foo.thin instead of foo.mydomain.com.

The only similar questions on SO advise checking the environment in the controller and setting the host based on that, but I'm sure this is supposed to be handled automatically. Is there something nginx and/or thin isn't passing to Rails that's needed to infer the host?

Upvotes: 0

Views: 80

Answers (1)

Asherlc
Asherlc

Reputation: 1161

I needed to preserve the host being passed from nginx to Thin with this:

proxy_set_header Host $host;

in the proxy pass block. i.e.:

location / {
    proxy_pass http://my_app_upstream;
    proxy_set_header Host $host;
    # ...
}

Upvotes: 1

Related Questions