simple auth question for nested sections

Jonathan Vanasco nginx at 2xlp.com
Wed Mar 23 00:00:13 UTC 2016


apologies for the simple question, but i could only find the opposite situation in the list archives and I haven't had to reconfigure some of these routes in years!

i have 

	# works
	location /foo {
		proxy_pass  http://127.0.0.1:6543;
	}

I want to lock down /foo/admin with basic auth

	# works
	location /foo/admin {
		proxy_pass  http://127.0.0.1:6543;
		auth_basic "Administrator Login";
		auth_basic_user_file /etc/nginx/_htpasswd/well-known;
	}

Is there a syntax for nesting the two together, so the /foo/admin would inherit the /foo configuration without the need to redeclare everything?

	# something like
	location /foo {
		proxy_pass  http://127.0.0.1:6543;
		location /foo/admin {
			auth_basic "Administrator Login";
			auth_basic_user_file /etc/nginx/_htpasswd/well-known;
		}
	}



More information about the nginx mailing list