I'm trying to set up a simple webserver to display some images loaded from my NAS. My problem is that I can only get the webserver to display images when they're stored in a folder on the Ubuntu-host. When trying to load them from my NAS, they appear as broken files on the webpage, but are accessible when accessing them directly by entering the complete file path in my browser.
The webserver is running inside Docker on a Ubuntu 20.04 host. I am using the httpd Docker-image. My compose-file looks like this:
version: '3'
services:
httpd:
container_name: webserver-test
image: httpd:2.4.38-alpine
restart: always
# environment:
# - PUID=1000
# - PGID=1000
ports:
- "80:80"
volumes:
- /mnt/744fa3d8-4c42-44fb-90a4-1cec0422ab15/data/containers/webserver-test/public-html/:/usr/local/apache2/htdocs
- /mnt/744fa3d8-4c42-44fb-90a4-1cec0422ab15/data/containers/webserver-test/configuration/:/usr/local/apache2/conf
- /mnt/nas-intern-delt-data/webtest/data/:/usr/local/apache2/htdocs/img
networks:
macvlan0:
ipv4_address: 192.168.10.210
networks:
macvlan0:
external: true
The mount-point /mnt/nas-intern-delt-data is mounted in fstab like so, and is browsable in Ubuntu without any problems:
//192.168.10.100/intern\040delt\040data /mnt/nas-intern-delt-data cifs username=user-here,password=password-here,vers=3.0,dir_mode=0777,file_mode=0777,uid=1000,gid=1000,iocharset=utf8 0 0
My index.html looks like this
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
</head>
<body>
<p>Hello world!</p>
<img src="/data/1.jpg">
<img src="/img/1.jpg">
</body>
</html>
When looking at the permissions at the data and img folders from inside the container I see this:
bash-4.4# cd /usr/local/apache2/htdocs
bash-4.4# ls -l
total 16
drwxrwxr-x 2 1000 1000 4096 Feb 10 16:53 data
drwxrwxrwx 2 1000 1000 0 Feb 10 19:29 img
-rwxr-xr-x 1 1000 1000 267 Feb 10 17:17 index.html
drwxrwxr-x 8 1000 1000 4096 Feb 9 20:33 pages
drwxr-xr-x 3 root 1000 4096 Feb 10 17:30 public-html
bash-4.4# cd data
bash-4.4# ls -l
total 100
-rwxr-xr-x 1 1000 1000 98588 Dec 14 16:20 1.jpg
bash-4.4# cd ..
bash-4.4# cd img
bash-4.4# ls -l
total 112
-rwxrwxrwx 1 1000 1000 98588 Dec 14 16:20 1.jpg
-rwxrwxrwx 1 1000 1000 4 Feb 10 19:32 test2.txt
bash-4.4#
The Apache-container logs shows the following when browsing the webpage:
192.168.2.124 - - [21/Feb/2021:15:40:07 +0000] "GET / HTTP/1.1" 304 -
192.168.2.124 - - [21/Feb/2021:15:40:07 +0000] "GET /img/1.jpg HTTP/1.1" 200 98588
The webpage itself looks like this: imgur-link
I hope that someone can shed some light on where this goes wrong. My guess is that it's a permissions problem, I just can't find it... As stated it shows the internally saved image fine, but not the one stored at my NAS.
Thanks in advance