[英]Why am I getting this Nginx error about “No such file or directory”?
I am trying to create a local pip2pi repo and then serve it up via Nginx. 我正在尝试创建本地pip2pi存储库,然后通过Nginx将其提供服务。 I have successfully created the repo and have all the wheel files I am wanting on my local machine.
我已经成功创建了存储库,并在本地计算机上拥有了我想要的所有wheel文件。 They are located like this:
它们的位置如下:
/home/user/code/misc/pip-packs/simple
\
---index.html
--- amqp
\
-------- index.html
-------- amqp-1.4.6-py2-none-any.whl
--- django
\
-------- index.html
-------- Django-1.9.3-py2.py3-none-any.whl
... ETC
Now to serve the files I am using Nginx on docker, simply using the official Nginx docker image. 现在要在docker上使用Nginx来提供文件,只需使用官方的Nginx docker镜像即可。 I run the container like this:
我这样运行容器:
docker run --name pypi-nginx -p 80:80 \
-v /home/user/code/misc/pip-packs/simple:/usr/share/nginx/html \
-d nginx
I can open localhost and see the index.html at root (/) and I can click on a link eg amqp and then get a link for the amqp-1.4.6-py2-none-any.whl file. 我可以打开本地主机,并在根目录(/)上看到index.html,然后单击链接,例如amqp,然后获取amqp-1.4.6-py2-none-any.whl文件的链接。 When I click on the link I expect a download to initiate.
当我单击链接时,我期望下载会启动。 Howver I get a 404 page from Nginx.
我如何从Nginx获取404页面。
THe file is definitely there, as I can run: 该文件肯定存在,因为我可以运行:
docker exec -it pypi-nginx /bin/bash
And then ls and the /usr/share/nginx/html directory and see all the files from the voulume. 然后是ls和/ usr / share / nginx / html目录,并查看voulume中的所有文件。
Further I can run pip install amqp-1.4.6-py2-none-any.whl on my local, so I know it's an actual wheel file. 此外,我可以在本地运行pip install amqp-1.4.6-py2-none-any.whl,所以我知道这是一个实际的wheel文件。
Nginx's official log error is: Nginx的官方日志错误是:
2016/05/20 14:48:01 [error] 7#7: *1 open() "/usr/share/nginx/html/funcsigs/funcsigs-0.4-py2.py3-none-any.whl" failed (2: No such file or directory), client: 172.17.0.1, server: localhost, request: "GET /funcsigs/funcsigs-0.4-py2.py3-none-any.whl HTTP/1.1", host: "localhost", referrer: "http://localhost/funcsigs/"
but yet it serves the index files in each firectory. 但它仍在每个目录中提供索引文件。 The nginx conf files I am using are the standard ones from the container.
我正在使用的nginx conf文件是容器中的标准文件。 I can post those if necessary.
如果有必要,我可以发布。
In the directory /home/user/code/misc/pip-packs/ is where pip2pi stores the packages it downloaded. 在目录/ home / user / code / misc / pip-packs /中,pip2pi存储了它下载的软件包。 So in /home/user/code/misc/pip-packs/ you have
所以在/ home / user / code / misc / pip-packs /
/home/user/code/misc/pip-packs/
\
--- amqp-1.4.6-py2-none-any.whl
--- Django-1.9.3-py2.py3-none-any.whl
--- ETC
Then as in the simple directory as described in the question above, each repo folder supposedly has the wheel file as well, yet there was a 404. Well i glossed over the dir2pi pip-packs/
command, which only created symlinks and did not copy the wheel files. 然后,如上面问题中所述,在简单目录中,每个repo文件夹也应该具有wheel文件,但其中有一个404。好吧,我
dir2pi pip-packs/
了dir2pi pip-packs/
命令,该命令仅创建了符号链接,没有复制轮子文件。 So when I mounted the volume to the container, the actual wheel files, that all the symlinks pointed to, never got copied to the container. 因此,当我将体积安装到容器上时,所有符号链接所指向的实际车轮文件都不会复制到容器中。
The output of 'ls -al' for the Django folder (packages/simple/django) is: Django文件夹(packages / simple / django)的“ ls -al”输出为:
drwxr-xr-x 2 bdew70 bdew70 4096 May 20 11:02 .
drwxr-xr-x 64 bdew70 bdew70 4096 May 20 11:02 ..
lrwxrwxrwx 1 bdew70 bdew70 39 May 20 11:02 Django-1.9.3-py2.py3-none-any.whl -> ../../Django-1.9.3-py2.py3-none-any.whl
-rwxr-xr-x 1 bdew70 bdew70 88 May 20 11:02 index.html
The solution is to make a Dockerfile and then ADD
the wheel files to the /user/share/nginx/ folder along with the html files to the /usr/share/nginx/html/ folder. 解决方案是制作一个Dockerfile,然后将wheel文件和html文件一起
ADD
到/ user / share / nginx /文件夹中。 The Dockerfile should look like this: Dockerfile应该如下所示:
FROM nginx
ADD packages/simple /usr/share/nginx/html/
ADD packages /usr/share/nginx
The moral of the story is to use '-al' (or create an alias for ls) when investigating file problems and to be careful of symlinks in Docker container volumes. 这个故事的寓意是在调查文件问题时使用“ -al”(或为ls创建别名),并注意Docker容器卷中的符号链接。 Especially if the symlink is relative and in the form
../../some-file
. 特别是如果符号链接是相对的,并且形式为
../../some-file
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.