[英]How to configure docker-compose.yml and nginx conf file to read an external drive?
I have nginx in a docker container.我在 docker 容器中有 nginx。 My
docker-compose.yml
is like this (simplified):我
docker-compose.yml
是这样的(简化版):
nginx:
volumes:
- /var/www/html:/www/:rw
- /media/storage:/storage/:rw
Where /var/www/html
is my website root and /media/storage
is an external drive in my host machine (Azure).其中
/var/www/html
是我的网站根目录, /media/storage
是我的主机 (Azure) 中的外部驱动器。
Now I'm trying to point the website URL example.com/downloads
to /storage
but without success.现在我试图将网站 URL
example.com/downloads
指向/storage
但没有成功。 My nginx/conf.d/example.com.conf
is as following (simplified):我的
nginx/conf.d/example.com.conf
如下(简化):
server {
listen 80 default;
server_name example.com;
# this works
root /www;
index index.php;
# this get a 404 error
location /downloads{
root /storage;
}
} }
But I get a 404 error for example.com/downloads
.但是我收到
example.com/downloads
的 404 错误。 What am I forgetting here?我在这里忘记了什么? The file permissions and owner to both paths are the same.
两个路径的文件权限和所有者是相同的。 I don't know if the bad configuration is in
example.com.conf
or in docker-compose.yml
.我不知道错误的配置是在
example.com.conf
还是在docker-compose.yml
。 How should I configure these?我应该如何配置这些?
I solved this myself using alias /storage;
我自己使用
alias /storage;
解决了这个问题alias /storage;
instead of root /storage
.而不是
root /storage
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.