Nginx rule for subdomains: ERR_TOO_MANY_REDIRECTS

Francis Daly francis at
Sat Jun 10 06:39:29 UTC 2017

On Fri, Jun 09, 2017 at 04:14:35AM -0400, iivan wrote:

Hi there,

> to me there seems to be some bug... It's very weird that it worked first and
> now it does not.

Perhaps a bug was fixed, and it should never have worked? I think that
without a specific complete problem report, it is going to be difficult
to learn how things were.

Does everything work as you want if you revert to your previous version
of nginx?

> For example:
> 			set $sub_domain '';
> 			if ($host ~* ^(.*)\.salva\.link$) {
> 				set $sub_domain $1;
> 			}
> $sub_domain is always '0'. Can you confirm me?

For me, if I use that config fragment in some supporting config, and
make some suitable http requests, the only way $sub_domain is 0 is if
I set Host to

If you can include a complete but small config with clear instructions
on how to generate the unexpected output that you see, there is a much
better chance that someone else will be able to reproduce it.

Back to your original problem report:

  nginx -T | grep 'location\|server'

might show enough of your actual running config to see where a request
for /index.cfm is handled. Limit the output to just the server{} block
that handles the request, if you have multiple unrelated server{}s in
the config.

Francis Daly        francis at

More information about the nginx mailing list