Francis Daly
July 31, 2019 07:56AM
On Tue, Jul 30, 2019 at 04:20:41PM -0500, J. Lewis Muir wrote:

Hi there,

> I have a minimal nginx.conf with one server block that sets the root
> directory but has *no* location directives, yet for a request of "/", it
> serves "/index.html". Why? With no locations specified, I expected it
> to return 404 or similar for any request.

As you've seen: if there is not a best-match location{} for this request;
then nginx uses the server{}-level config. Without other configuration,
that will eventually default to serving from the filesystem with the
defined root directory.

If *that* directory or file is not there, you'll get a 404.

(And there is a compile-time root directory, if you do not set "root"
explicitly.)

In the common case, you want a "location / {}" so that there will always
be a best-match location{}.

Perhaps this "no-location-matched" case could be documented more clearly?

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Implicit root location?

J. Lewis Muir July 30, 2019 05:22PM

Re: Implicit root location?

Francis Daly July 31, 2019 07:56AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 261
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready