Location url start with modifier, nginx -t pass the configuration test

Maxim Dounin mdounin at mdounin.ru
Fri Feb 10 12:45:02 UTC 2017


On Fri, Feb 10, 2017 at 01:31:34PM +0800, linbo liao wrote:

> I setup an test Nginx 1.10.3 on local VM (Centos 6.7 x86_64). I configure
> the following location
> location =/404.html {
>     root    /usr/share/nginx/html;
> }
> As my understanding, it is not an valid url, but `nginx -t`  pass the
> configuration test.
> Is it a bug ?

In this particular case the location is interpreted as "/404.html" 
with "=" modifier (see http://nginx.org/r/location).  That is, it 
matches requests to "/404.html" exactly.  Space between "=" and 
"/404.html" can be omitted, and nginx is smart enough to recognize 

On the other hand, there are no limitations on locations to 
configure in nginx.conf.  You can configure anything you like, 
even locations which can't match real URIs.  Moreover, such 
locations can used for artificial processing with rewrites, and 
I've seen such configs in practice.  This is not something I can 
recommend though.

Maxim Dounin

More information about the nginx mailing list