[PATCH v4 07/12] Static: add "index" option

Alejandro Colomar (man-pages) alx.manpages at gmail.com
Mon Feb 14 11:33:21 UTC 2022


Hi, Andrei!

On 1/28/22 13:27, Andrei Zeliankou wrote:
>> On 23 Dec 2021, at 19:25, Alejandro Colomar <alx.manpages at gmail.com> wrote:
>>
>> This supports a new option "index", that configures a custom index
>> file name that will be served when a directory is requested.  This
>> initial support only allows a single fixed string.  An example:
>>
>> {
>> 	"share": "/www/data/static/$uri",
>> 	"index": "lookatthis.htm"
>> }
>>
[...]

> Also noticed problems:
> 
> 1) can't compile patch set with specified `--debug` option:
> 
> src/nxt_http_static.c:264:23: error: no member named 'index' in 'nxt_http_static_conf_t'
>      nxt_var_raw(conf->index, &idx);
>                  ~~~~  ^

Oops, fixed.

> 
> 2) router crash when index is the empty array

I'm still investigating this one.

> 
> 3) router crash when variable in index value is empty

The same behavior happens when you set up index to the name of a dir:

$ cat config.json
{
	"listeners": {
		"*:80": {
			"pass": "routes"
		}
	},

	"routes": [
		{
			"action": {
				"share": "/home/alx/srv/www/static/$uri",
				"index": "dir"
			}
		}
	]
}
$ ls -l /home/alx/srv/www/static/
total 16
-rw-r--r-- 1 alx alx    4 Dec 14 17:51 GET.html
drwxr-xr-x 2 alx alx 4096 Feb 14 12:18 dir
-rw-r--r-- 1 alx alx    6 Dec 14 17:52 index.html
-rw-r--r-- 1 alx alx   10 Dec 15 12:55 localhost.html


$ curl --dump-header - http://localhost
HTTP/1.1 301 Moved Permanently
Location: //
Server: Unit/1.27.0
Date: Mon, 14 Feb 2022 11:19:24 GMT
Content-Length: 0


Setting "dir/" instead of "dir" behaves identically too.

What is the expected behavior when trying to serve a directory?  With 
old nginx (open-source), with autoindex off, and try_files ${uri}/, I'm 
getting 403 Forbidden.  Where does Unit decide about that?


Thanks,

Alex

-- 
Alejandro Colomar
Linux man-pages comaintainer; http://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/



More information about the unit mailing list