Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#757 closed defect (invalid)

map fails to match hostnames values - possibly following proxy_pass

Reported by: Steeve Knight Owned by:
Priority: minor Milestone:
Component: nginx-module Version: 1.7.x
Keywords: map Cc:
uname -a: Linux <drop-name> 3.16.0-28-generic #37-Ubuntu SMP Mon Dec 8 17:15:28 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: 0.91-ubuntu1


The following map sets up a value for my Access-Control-Allow-Origin

map $http_origin $corsHost {

default '-missed-me-ha-ha-';

hostnames; $http_origin;

#this never works $http_origin;

#this works fine $http_origin;


Any of and proxy to via proxy_pass. and then may make requests (usualy async) directly to Requests to work just fine and $corsHost is set properly Requests to always fail and $corsHost is set to default.
Workaround is as above, avoiding the hostname combo and using the full request Origin string.

Change History (3)

comment:1 by Maxim Dounin, 9 years ago

Resolution: invalid
Status: newclosed

The map with hostnames is to match hostnames, not URLs. The is expected to match and, but not - as it's know nothing about https:// being special and doesn't know how is different from

See docs more details.

comment:2 by Steeve Knight, 9 years ago

Nope - sorry, you missed it, and in fact the added comment will likely just inject confusion.
<quote>The is expected to match and</quote>
I'm telling the above DOES NOT MATCH.
Further, removing the #this works fine pair, and $http_origin being a fully qualified URL, NEVER MATCHES the hostname, however if I change the default to $http_origin and test, in fact is returned into $corsHost, so I have thereby verified the test string. It fails where it should be matching.

comment:3 by Maxim Dounin, 9 years ago

Again: URLs and hostnames are different things. And is not a hostname. When parsed as a hostname, it's more like, and it's _not_ expected to be matched. Try with instead (without the https:// prefix), it will be matched.

Note: See TracTickets for help on using tickets.