简体   繁体   中英

How to configure docker-compose.yml and nginx conf file to read an external drive?

I have nginx in a docker container. My docker-compose.yml is like this (simplified):

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).

Now I'm trying to point the website URL example.com/downloads to /storage but without success. My nginx/conf.d/example.com.conf is as following (simplified):

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 . 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 . How should I configure these?

I solved this myself using alias /storage; instead of root /storage .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM