* 1目录索引“/usr/share/nginx/html/”在mac Catalina 操作系统中被禁止

nbewdwxp  于 2023-02-21  发布在  Nginx
关注(0)|答案(1)|浏览(449)

我试图将一个文件夹挂载到“/usr/share/nginx/html/“中,Docker控制台显示错误“[error] 28#28: *1 directory index of /usr/share/nginx/html/ is forbidden“。我使用此命令挂载卷“docker-share dilrukshi$ docker run -d -p 8080:80 --name web -v ~/docker-share/html:/usr/share/nginx/html nginx“,还使用了nginx/1. 19. 3官方NGINX Docker映像。在网页显示中,一个“403禁止”的错误,也“/usr/share”文件夹没有“/nginx/html”.什么是错的?和我如何修复它?

坞站控制台

/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
172.17.0.1 - - [20/Oct/2020:07:09:41 +0000] "GET / HTTP/1.1" 403 555 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36" "-"
2020/10/20 07:09:41 [error] 28#28: *1 directory index of "/usr/share/nginx/html/" is forbidden, client: 172.17.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost:8080"

浏览器错误

6mzjoqzu

6mzjoqzu1#

文件夹权限似乎有问题。请尝试执行以下操作:

chmod -R 755 ~/docker-share/html

当您将主机文件夹Map到容器中时,文件的所有权将保持不变。
如果执行以下命令

docker run -it --rm -v "~/docker-share/html:/usr/share/nginx/html" nginx:alpine

你会得到这样的结果:

total 12
drwx--x--x    2 1000     1000          4096 Oct 20 07:48 .
drwxr-xr-x    3 root     root          4096 Jan  9  2020 ..
-rwx--x--x    1 1000     1000            83 Oct 20 07:48 index.html

在我的例子中,文件夹由1000拥有(在您的例子中,您将找到您的uid)。nginx容器将使用nginx用户(uid:101)的工人。

相关问题