$upstream_http_* variables exist but do not seem to be readable

shrikeh nginx-forum at nginx.us
Fri Feb 1 13:59:38 UTC 2013


Hi,

I'm currently using OpenResty, and one of the things I am trying to do is
have the backend send a specific header, and if that header is present, run
a body_filter_by_lua call on the output. However, while I can use the
$upstream_http_* vars for populating (i.e. I can go add_header SomeHeader
$upstream_http_foo, and if Foo has been sent see SomeHeader: FooVar in the
output. However, all tests for them seem to break.

Example:

location @backend {
		expires off;
		proxy_pass http://_varnish;
                set $test $upstream_http_csrf; # definitely exists, I can
see it in the response headers
                add_header SomeHeader $upstream_http_csrf; # And I can read
it, but....
                if ($upstream_http_csrf = 1) { # doesn't matter if it's 1,
"one" ~* "one", anything....
                # this block never gets called
                }
                add_header someOtherHeader $test; # Not present in output as
empty
		set_by_lua $use_token
		'
		if not ngx.var.sent_http_csrf  == "" then
			return ngx.var.upstream_http_csrf
		end
		return "baz"
		'; # Always return 'baz'
                add_header WIllThisWork $use_token; # Again, empty
}

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,235808,235808#msg-235808



More information about the nginx mailing list