From: "Iñaki Baz Castillo" <ibc@aliax.net>
To: mongrel-unicorn@rubyforge.org
Subject: Re: X-Forwarded-Proto / X_FORWARDED_PROTO
Date: Sat, 9 Jan 2010 23:33:41 +0100 [thread overview]
Message-ID: <201001092333.41898.ibc@aliax.net> (raw)
In-Reply-To: <20100109221656.GA8846@waste.org>
El Sábado, 9 de Enero de 2010, skaar escribió:
> Eric,
>
> think I came across an issue with the parser in unicorn, with a request
> (due to 2 layers of nginx proxying) coming across with both a
> X_FORWARDED_PROTO and a X-Forwarded-Proto header. From the socket (in
> HttpRequest) - we get:
>
> X_FORWARDED_PROTO: http
> X-Forwarded-Proto: https
>
> which is parsed to
>
> HTTP_X_FORWARDED_PROTO"=>"http,https
>
> There was a passenger ticket that describes that from nginx's point of
> view - X-Forwarded-Proto is the "correct" form.
Rack specs require "-" being converted to "_" in header names, so both header
X_FORWARDED_PROTO and X-Forwarded-Proto become the same header.
Then we have two headers with same name and different value. Some headers are
defined as "multivalue" which means that they would have the same meaning if
an unique header exists containing both values separated by comma (the top one
first). So:
X_FORWARDED_PROTO: http
X-Forwarded-Proto: https
is equivalent to:
X_FORWARDED_PROTO: http, https
However it's not true that *any* header behaves in this way, but just headers
defined in such way (by the standards). For example two "Authorization"
headers cannot be joined in a single header.
So it's not totally safe to assume that any header appearing various times
could be a single header with their values separated by comma, however I think
it's a good approach.
More correct would be that Unicorn parses uknown headers appearing more than
one time by setting a Array as value:
X_FORWARDED_PROTO: ["http", "https"]
Unfortunately this is not allowed in Rack specifications.
--
Iñaki Baz Castillo <ibc@aliax.net>
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying
next prev parent reply other threads:[~2010-01-09 22:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-09 22:16 X-Forwarded-Proto / X_FORWARDED_PROTO skaar
2010-01-09 22:33 ` Iñaki Baz Castillo [this message]
2010-01-09 22:39 ` Eric Wong
2010-01-09 23:29 ` skaar
2010-01-09 23:45 ` Iñaki Baz Castillo
2010-01-10 6:12 ` Eric Wong
2010-01-10 6:32 ` Eric Wong
2010-01-10 11:43 ` John-Paul Bader
2010-01-19 21:43 ` Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/unicorn/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201001092333.41898.ibc@aliax.net \
--to=ibc@aliax.net \
--cc=mongrel-unicorn@rubyforge.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/unicorn.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).