#77 ✓resolved
Austin Taylor

[PATCH] request.host should answer the forwarded host.

Reported by Austin Taylor | October 5th, 2009 @ 05:57 PM | in 1.1

It seems like this should be Rack's responsibility, but I see that Rails is handling it in ActionController::Request like this:

    # Returns the \host for this request, such as "example.com".
    def raw_host_with_port
      if forwarded = env["HTTP_X_FORWARDED_HOST"]
        env['HTTP_HOST'] || "#{env['SERVER_NAME'] || env['SERVER_ADDR']}:#{env['SERVER_PORT']}"

    # Returns the host for this request, such as example.com.
    def host
      raw_host_with_port.sub(/:\d+$/, '')

This is important when you are using a proxy server (mongrel, thin) and want your application to display an absolute url for some reason. This isn't working in Sinatra right now. I reported the behavior on the Sinatra Lighthouse and they directed me here. Sinatra ticket

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket