﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	uname	nginx_version
1473	Odd variable sets with proxy_pass	Shinrai@…		"nginx.conf:

{{{

	server {
        listen       ****************:80;
        server_name  cdn.cldmv.net;

		set $fastcgihost ****************;
		set $fastcgiport ****************;
		set $fastcgihostname $fastcgihost:$fastcgiport;
		set $chrootdir ****************/cdn.cldmv.net/html;
		set $globalchroot ****************;
		fastcgi_intercept_errors on;
		
		include ****************/templates/base/setup.conf;

		root   $globalchroot****************/cdn.cldmv.net/html;

        access_log  ****************/cdn.cldmv.net/logs/access.log  main;
        error_log  ****************/cdn.cldmv.net/logs/error.log;

		index  index.php index.html index.htm;
		autoindex on;
		
		#fancyindex on;              # Enable fancy indexes.
		#fancyindex_exact_size off;  # Output human-readable file sizes.
		#fancyindex_ignore
		#concat on;
		#concat_max_files 30;
		
		include ****************/templates/software/vhost.conf;
    }
	
	server {
        listen       ****************:80;
        server_name  cdn2.cldmv.net;

		set $fastcgihost ****************;
		set $fastcgiport ****************;
		set $fastcgihostname $fastcgihost:$fastcgiport;
		set $chrootdir ****************/cdn.cldmv.net/html;
		set $globalchroot ****************;
		fastcgi_intercept_errors on;
		
		include ****************/templates/base/setup.conf;

		root   $globalchroot****************/cdn.cldmv.net/html;

        access_log  ****************/cdn.cldmv.net/logs/access.log  main;
        error_log  ****************/cdn.cldmv.net/logs/error.log;

		index  index.php index.html index.htm;
		autoindex on;
		
		#fancyindex on;              # Enable fancy indexes.
		#fancyindex_exact_size off;  # Output human-readable file sizes.
		#fancyindex_ignore
		#concat on;
		#concat_max_files 30;
		set $_robots_index ""disabled"";
		set $_seo_process_trail ""disabled"";
		
		location /cldmv/jquery/ {
			add_header X-DIR-Test ""success"";
			set $_robots_index ""enabled"";
			set $_seo_process_trail ""enabled"";
		}
		
		include ****************/templates/software/vhost.conf;
    }
	
	server {
        listen       ****************:80;
        server_name  cdn3.cldmv.net;

		set $fastcgihost ****************;
		set $fastcgiport ****************;
		set $fastcgihostname $fastcgihost:$fastcgiport;
		set $chrootdir ****************/cdn.cldmv.net/html;
		set $globalchroot ****************;
		fastcgi_intercept_errors on;
		
		include ****************/templates/base/setup.conf;

		root   $globalchroot****************/cdn.cldmv.net/html;

        access_log  ****************/cdn.cldmv.net/logs/access.log  main;
        error_log  ****************/cdn.cldmv.net/logs/error.log;

		index  index.php index.html index.htm;
		autoindex on;
		
		#fancyindex on;              # Enable fancy indexes.
		#fancyindex_exact_size off;  # Output human-readable file sizes.
		#fancyindex_ignore
		#concat on;
		#concat_max_files 30;
		set $_robots_index ""disabled"";
		set $_seo_process_trail ""disabled"";
		
		location /cldmv/jquery/ {
			add_header X-DIR-Test ""success"";
			set $_robots_index ""enabled"";
			set $_seo_process_trail ""enabled"";
			include ****************/templates/base/base/seo.conf;
		}
		
		include ****************/templates/software/vhost.conf;
    }
}}}

All of the above configs works as intended. 

http://cdn3.cldmv.net/cldmv/jquery/ produces the headers:

{{{
X-DIR-Test:success
X-Robots-Parse:index
X-Robots-Tag:all
X-SEO-Test:get
X-SEO-Trail:get_process_seo_trail
}}}
and include ****************/templates/base/base/seo.conf; is not needed.


http://cdn2.cldmv.net/cldmv/jquery/ produces the headers:

{{{
X-DIR-Test:success
X-Robots-Parse:index
X-Robots-Tag:all
X-SEO-Test:get
X-SEO-Trail:get_process_seo_trail
}}}

http://cdn2.cldmv.net/cldmv/ produces the headers:

{{{
X-Robots-Parse:no_index
X-Robots-Tag:noindex, noarchive, nosnippet, nofollow
X-SEO-Test:get
X-SEO-Trail:get_skip_seo_trail
}}}

However when the above cdn.cldmv.net nginx.conf block is paired with a proxy_pass block like so:

{{{

		location ~ ****************/nas1(.*)$ {
			set $_seo_process_trail ""disabled"";
			set $_robots_index ""disabled"";
			access_log  ****************/logs/nas1-access.log  main;
			error_log  ****************/logs/nas1-error.log;
			#proxy_buffering on;
			proxy_connect_timeout 3600;
			proxy_send_timeout 3600;
			proxy_read_timeout 3600;
			proxy_redirect off;
			proxy_max_temp_file_size 0;
			proxy_buffer_size 16k;
			proxy_buffers 64 16k;
			proxy_busy_buffers_size 16k;
			#proxy_max_temp_file_size 2048m;
			proxy_temp_file_write_size 32k;
			proxy_set_header Host $host;
			proxy_set_header X-Forwarded-Proto $scheme;
			proxy_set_header X-Url-Scheme $scheme;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header X-Forwarded-Port $server_port;
			proxy_set_header X-Forwarded-Server $host;
			proxy_set_header X-Forwarded-Host $host;
			
			proxy_buffering off;
			proxy_request_buffering off;
			proxy_http_version 1.1;
			proxy_set_header Connection """";
			
			proxy_pass http://****************$1;
			#include ****************/templates/base/base/seo.conf;
			#include ****************/templates/base/base/seo/x-robots.conf;
		}
}}}


Both
{{{
	set $_seo_process_trail ""disabled"";
	set $_robots_index ""disabled"";
}}}
do not apply and I'm left with the following headers:

{{{
x-robots-parse:index
x-robots-tag:all
x-seo-test:get
x-seo-trail:get_process_seo_trail
}}}

However if I add
{{{
add_header X-Robots-Tag ""noindex, noarchive, nosnippet, nofollow"";
}}}
to the proxy_pass block than none of the headers apply, not even my debug ones.

Though when accessing /nas1 instead of /nas1/ I do get:

{{{
x-robots-parse:index
x-robots-tag:all
x-seo-test:get
x-seo-trail:get_process_seo_trail
}}}
and a redirect to /nas1/ via the code in the ****************/templates/base/base/seo.conf


So this bug is two fold. 

One being that if I access /nas1/url/admin none of my proxy pass block is applied and it skips over it and applies the base server block config. Thus redirecting me to /nas1/url/admin/. Once at /nas1/url/admin/ I get the expected headers IF and only IF I specify an add_header directive in the proxy_pass block. If add_header is NOT specified the headers which should have been parsed through the variables set in the proxy_pass block are not parsed correctly. Even though the variables being specified in the proxy_pass block are in fact set and sent out via add_header.


Expected behavior is that the URL matches the proxy_pass block and thus the set variables are applied. Then the remaining config is ran and the headers are sent out as the conditional headers. As shown to work in the cdn* configs.
"	defect	closed	major		nginx-core	1.12.x	invalid	rewrite		Linux ws.c2.cldmv.net 3.10.0-327.36.2.el7.x86_64 #1 SMP Mon Oct 10 23:08:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux	"nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'"
