how nginx decide which server block to use

Francis Daly francis at
Wed Jun 21 21:57:44 UTC 2017

On Wed, Jun 21, 2017 at 03:26:10PM +0800, George / wrote:

Hi there,

For the question in the Subject: line, see

>   i am running nginx version: nginx/1.12.0.i got following server block config as below, all request match regular expression work well,but request to server return 404.what's wrong? i googled for a while,most of the article said,it first try to match literal string ,then wildcard,and regular expression last. 

When you make a request for, do you connect to [ip1],
[ip2], [ip3], or something else?

Which server{} do you think is being used? Which server do you want nginx to use?

For what it is worth, a config line like

        try_files $uri $uri/ @apache =404;

will never try to use the @apache location.

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list