Open dhop90 opened 1 month ago
I ran into an similar Issue with external Traefik, the Backend Container needs to expose the /media PathPrefix.
labels:
- "traefik.enable=true"
- "traefik.http.routers.adventurelog.entrypoints=websecure"
- "traefik.http.routers.adventurelog.rule=Host(`yourdomain.com`) && PathPrefix(`/media`)" # Replace with your domain
- "traefik.http.routers.adventurelog.tls=true"
- "traefik.http.routers.adventurelog.tls.certresolver=letsencrypt"
before 0.7.1 this was done by the separate nginx, in the current example Config nothing is providing this Path.
Thanks @lovwyr! I am unfamiliar with how Traefik works but do you recommend I update the docker compose Traefik version with these changes you provided? Thanks!
@seanmorley15 yes please :)
web Container
labels:
- "traefik.enable=true"
- "traefik.http.routers.adventurelogweb.entrypoints=websecure"
- "traefik.http.routers.adventurelogweb.rule=Host(`yourdomain.com`) && !PathPrefix(`/media`)" # Replace with your domain
- "traefik.http.routers.adventurelogweb.tls=true"
- "traefik.http.routers.adventurelogweb.tls.certresolver=letsencrypt"
server Container
labels:
- "traefik.enable=true"
- "traefik.http.routers.adventurelogserver.entrypoints=websecure"
- "traefik.http.routers.adventurelogserver.rule=Host(`yourdomain.com`) && PathPrefix(`/media`)" # Replace with your domain
- "traefik.http.routers.adventurelogserver.tls=true"
- "traefik.http.routers.adventurelogserver.tls.certresolver=letsencrypt"
maybe it would be an Idea to move the serving of the Images from the Backend to the Frontend Container?
Thanks @lovwyr, but can't seem to get this to work for my setup. I was able to create an ingress rule for /media routed to the server:8000 and can access https://adventure.domain.duckdns.org/media/profile-pics/dhop-avatar.webp along with flags in the /media/maps directory. I'm wondering if I need to replace /media with /app/media since that is what the nginx proxy was doing. Not 100% how to do that.
@dhop90 i think the ingress route/port should be 80, the 8000 is the internal django
labels:
- "traefik.enable=true"
- "traefik.docker.network=proxy"
- "traefik.http.routers.adventurelogserver.entrypoints=websecure"
- "traefik.http.routers.adventurelogserver.rule=Host(`adventurelog.${DOMAIN}`) && PathPrefix(`/media`)"
- "traefik.http.services.adventurelogserver.loadbalancer.server.port=80"
- "traefik.http.routers.adventurelogserver.service=adventurelogserver"
this is my current docker only config which works. unfortunately i had no k8s available to test it.
mhh after reading again :)
the nginx serves the media files from /code/media, i only had an bind mount for this
@lovwyr when I access both port 80 and 8000 it takes me to the internal django API Server, and both ports when configured for the ingress route allows me to access https://adventure.domain.duckdns.org/media/profile-pics/dhop-avatar.webp
Got it working, I'll provide details tomorrow
Describe the bug Images and profile picture are not displayed when accessing application. I've reviewed https://github.com/seanmorley15/AdventureLog/issues/288 as well as post on reddit https://www.reddit.com/r/selfhosted/comments/1eswkgd/adventurelog_self_hosted_travel_tracker_and/ but have not been able to get this to work.
To Reproduce Steps to reproduce the behavior:
server -
web -
Expected behavior World Travel map images are displayed as well as uploaded profile picture
Screenshots If applicable, add screenshots to help explain your problem.
Docker Compose See configs above
Additional context Server Logs: System check identified no issues (0 silenced). October 19, 2024 - 15:55:11 Django version 5.0.8, using settings 'main.settings' Starting development server at http://0.0.0.0:8000/ Quit the server with CONTROL-C. "GET /auth/user/ HTTP/1.1" 200 297 "GET /auth/user/ HTTP/1.1" 200 297 "GET /api/countries/ HTTP/1.1" 200 40732 "GET /auth/user/ HTTP/1.1" 200 297 "GET /api/adventures/filtered?types=all&order_by=updated_at&order_direction=asc&include_collections=false&page=1 HTTP/1.1" 301 0 Ordering by: -updated_at "GET /api/adventures/filtered/?types=all&order_by=updated_at&order_direction=asc&include_collections=false&page=1 HTTP/1.1" 200 52 "GET /auth/user/ HTTP/1.1" 200 297 "GET /api/adventures/filtered?types=all&order_by=updated_at&order_direction=asc&include_collections=false&page=1 HTTP/1.1" 301 0 Ordering by: -updated_at "GET /api/adventures/filtered/?types=all&order_by=updated_at&order_direction=asc&include_collections=false&page=1 HTTP/1.1" 200 52 "GET /auth/user/ HTTP/1.1" 200 297 "GET /api/collections/?order_by=updated_at HTTP/1.1" 200 828
Web Logs: user: { pk: 2, profile_pic: 'http://server.domain.duckdns.org/media/profile-pics/user.webp', uuid: 'b387387f-6e35-4fb7-af9b-764a9862cbf9', public_profile: true, username: 'user', email: 'user@gmail.com', first_name: 'First', last_name: 'Last', date_joined: '2024-10-17T01:03:15Z', is_staff: true }, props: { countries: [ [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], ... 150 more items ] } }
profile-pics ~ % curl http://server.domain.duckdns.org/media/profile-pics/user.webp
~ % ping server.domain.duckdns.org PING server.domain.duckdns.org (192.168.86.19): 56 data bytes 64 bytes from 192.168.86.19: icmp_seq=0 ttl=64 time=3.970 ms 64 bytes from 192.168.86.19: icmp_seq=1 ttl=64 time=1.168 ms ^C --- server.domain.duckdns.org ping statistics --- 2 packets transmitted, 2 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 1.168/2.569/3.970/1.401 ms
From the server container, wget works for index.html:
but trying to get an image, does not:
file exists: