Browse files

Headers work with nginx

This fixes a big problem with nginx. nginx does not send some headers if they have an underscore in them. Since this is a Rack middleware, all headers will be converted into HTTP_FOO_BAR. The original header may have been Foo-Bar or Foo_Bar. We may never know. Actually is a very annoying problem with rack because you can't access the original headers. So, we simply replace `_`'s with `-` and everything is cool. Most likely the `_`'s were `-`'s in the first place.
  • Loading branch information...
1 parent c174271 commit 1ee4d469a02f5997152ecc64140e6bab54bf78da Adam Hawkins committed Apr 18, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/rack/reverse_proxy.rb
2 lib/rack/reverse_proxy.rb
@@ -20,7 +20,7 @@ def call(env)
headers =
env.each { |key, value|
if key =~ /HTTP_(.*)/
- headers[$1] = value
+ headers[$1.gsub("_", "-")] = value
headers['HOST'] = if all_opts[:preserve_host]

0 comments on commit 1ee4d46

Please sign in to comment.