Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some content not working when behind Traefik reverse proxy #239

Closed
5 tasks done
arcoast opened this issue Jul 24, 2023 · 64 comments
Closed
5 tasks done

Some content not working when behind Traefik reverse proxy #239

arcoast opened this issue Jul 24, 2023 · 64 comments

Comments

@arcoast
Copy link
Contributor

arcoast commented Jul 24, 2023

Describe the bug

Add a podcast (it doesn't seem to matter which modality used, ie Apple Podcasts, Podindex or my preferred, rss feed) but the icons are not displayed for some podcasts, to clarify, if they work for a podcast series, all the episodes have the thumbnail, if it doesn't work for a podcast series, then none of the episodes have a thumbbail.

I'm installing podfetch with docker-compose, currently on v4.0.1-16173cd2 (HEAD)

    podfetch:
        image: samuel19982/podfetch:postgres
        container_name: podfetch
        networks:
            - podfetch
            - traefik
        user: 99:100
        environment:
            - POLLING_INTERVAL=${POLLING_INTERVAL}
            - SERVER_URL=${SERVER_URL}
#            - GPODDER_INTEGRATION_ENABLED=${GPODDER_INTEGRATION_ENABLED}
            - PODINDEX_API_KEY=${PODINDEX_API_KEY}
            - PODINDEX_API_SECRET=${PODINDEX_API_SECRET}
            - DATABASE_URL=${DATABASE_URL}
            - DB_CONNECTIONS=${DB_CONNECTIONS}
        volumes:
            - ${PODCASTS}:/app/podcasts
            - ${CONFIG}/podfetch:/app/db
#        ports:
#            - 8000:8000
        restart: always
        labels:
            - "traefik.enable=true"
            - "traefik.http.routers.podfetch.middlewares=authelia@file, securityHeaders@file"

    podfetch-postgres:
        image: postgres
        container_name: podfetch-postgres
        networks:
            - podfetch
        environment:
            - POSTGRES_DB=${PODFETCH_POSTGRES_DB}
            - POSTGRES_USER=${PODFETCH_POSTGRES_USER}
            - POSTGRES_PASSWORD=${PODFETCH_POSTGRES_PASSWORD}
        volumes:
            - ${CONFIG}/podfetch-postgres:/var/lib/postgresql/data
        restart: unless-stopped

My .env file

# Podfetch

POLLING_INTERVAL=60
SERVER_URL=https://podfetch.SERVER.COM
GPODDER_INTEGRATION_ENABLED=false
PODINDEX_API_KEY=MY_API_KEY
PODINDEX_API_SECRET=MY_API_SECRET
DATABASE_URL=postgresql://podfetch:password@podfetch-postgres/podfetch
DB_CONNECTIONS=10
PODFETCH_POSTGRES_DB=podfetch
PODFETCH_POSTGRES_USER=podfetch
PODFETCH_POSTGRES_PASSWORD=password

The relevant icon file is indeed present in the folder, it doesn't matter whether the podcast episodes are renamed or not. In the example below, I'm not renaming, but it has no effect either way.

root@server:/mnt/user/podcasts/LINUX Unplugged# ls -la
total 8
drwxr-xr-x 1 nobody users 4096 Jul 24 23:30 ./
drwxrwxrwx 1 nobody users    6 Jul 24 23:34 ../
drwxr-xr-x 1 nobody users   54 Jul 24 23:30 0120f9a1-0f24-430b-ba74-84fd7b185b5b/
drwxr-xr-x 1 nobody users   54 Jul 24 23:30 077a4216-c47b-47ce-8632-9201e81b6f30/
drwxr-xr-x 1 nobody users   42 Jul 24 23:30 38317c5e-8541-447c-9bdb-bdb64923deea/
drwxr-xr-x 1 nobody users   54 Jul 24 23:30 5773516d-88a4-4eb6-95b4-d4e4ebb3bcfa/
drwxr-xr-x 1 nobody users   54 Jul 24 23:30 684c5ff8-088f-499e-886a-50dc94731934/
drwxr-xr-x 1 nobody users   54 Jul 24 23:30 934efe4c-9766-4c75-b842-158ad66eacf1/
drwxr-xr-x 1 nobody users   54 Jul 24 23:30 b847af35-ad5c-4ed0-a0de-b602bded9c16/
drwxr-xr-x 1 nobody users   54 Jul 24 23:30 bc9e23ff-dbfe-4ec1-8b63-04c2ddcc97f1/
drwxr-xr-x 1 nobody users   54 Jul 24 23:30 d3922dbc-ffc8-4cf5-80fe-38511abd3184/
drwxr-xr-x 1 nobody users   54 Jul 24 23:30 eecdc671-ec5b-44a5-992f-346f2f2eb090/
-rw-r--r-- 1 nobody users   38 Jul 24 23:30 image.jpg

The files have the correct permissions:

root@server:/mnt/user/podcasts/LINUX Unplugged# id nobody
uid=99(nobody) gid=100(users) groups=100(users),98(nobody)

It doesn't seem to matter whether I use Firefox or Brave and trying an incognito session doesn't fix the issue.
I've #ed out the podcasts down below that are unaffected.

root@server:/# docker exec -it podfetch /app/podfetch podcasts list
Debug file located at /home/rust/src/target/x86_64-unknown-linux-musl/release/build/podfetch-47ad4ae1dbcbace8/out/built.rs
Starting from command line
Podcast management
Connecting to postgresql://podfetch:Gray1-Postage-Blurry@podfetch-postgres/podfetch
Id - Name - RSS Feed
15 - Linux Action News - https://linuxactionnews.com/rss
8 - 99% Invisible - https://feeds.simplecast.com/BqbsxVfO
13 - Coder Radio - https://feeds.fireside.fm/coder/rss
#12 - Ask The Hosts - https://askthehosts.com/feed/podcast/
#10 - Linux Downtime - https://latenightlinux.com/feed/extra
16 - LINUX Unplugged - https://linuxunplugged.com/rss
#11 - Linux After Dark - https://linuxafterdark.net/feed/podcast
19 - Ask Noah Show - https://podcast.asknoahshow.com/rss
18 - Self-Hosted - https://selfhosted.show/rss
17 - Office Hours - https://www.officehours.hair/rss
#9 - Late Night Linux - https://latenightlinux.com/feed/mp3
14 - Jupiter Extras - https://extras.show/rss

Nothing is in the logs that I can see either.

Reproduction

Use docker-compose above

System Info

N/A

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
@arcoast
Copy link
Contributor Author

arcoast commented Jul 27, 2023

Here's a list of the podcast feeds which I've found issues with

21 - 99% Invisible - https://feeds.simplecast.com/BqbsxVfO
5 - Ask Noah Show - https://feeds.fireside.fm/asknoah/rss
8 - Coder Radio - https://coder.show/rss
27 - Distrohoppers' Digest - https://feeds.redcircle.com/231a2905-0222-4327-b268-818d280f4d79
74 - Hardware Addicts - https://hardwareaddicts.org/rss
22 - Jupiter Extras - https://extras.show/rss
23 - Linux Action News - https://linuxactionnews.com/rss
32 - Linux For Everyone - https://www.linux4everyone.com/rss
73 - Linux Out Loud - https://dlnxtend.com/rss
24 - LINUX Unplugged - https://linuxunplugged.com/rss
25 - Office Hours - https://www.officehours.hair/rss
26 - Self-Hosted - https://selfhosted.show/rss
72 - Sudo Show - https://sudo.show/rss
9 - TechSNAP - https://feeds.fireside.fm/techsnap/rss
20 - This American Life - https://www.thisamericanlife.org/podcast/rss.xml
76 - User Error - https://error.show/rss

Looking at the XML for the top podcast as an example

https://podfetch.SERVER.COM/rss/21
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
<channel>
<title>99% Invisible</title>
<link>https://podfetch.SERVER.COM/rss/21</link>
<description>Design is everywhere in our lives, perhaps most importantly in the places where we've just stopped noticing. 99% Invisible is a weekly exploration of the process and power of design and architecture. From award winning producer Roman Mars. Learn more at 99percentinvisible.org.</description>
<language>en-us</language>
<category>Arts</category>
<itunes:author>Roman Mars</itunes:author>
<itunes:category text="Arts"/>
<itunes:image href="https://podfetch.SERVER.COM/podcasts/99% Invisible/image.jpg"/>
<itunes:explicit>false</itunes:explicit>
<itunes:new-feed-url>https://podfetch.SERVER.COM/rss/21</itunes:new-feed-url>
<itunes:owner>
<itunes:name>Roman Mars</itunes:name>
<itunes:email>local@local.com</itunes:email>
</itunes:owner>
<itunes:summary>Design is everywhere in our lives, perhaps most importantly in the places where we've just stopped noticing. 99% Invisible is a weekly exploration of the process and power of design and architecture. From award winning producer Roman Mars. Learn more at 99percentinvisible.org.</itunes:summary>
<itunes:keywords>Arts</itunes:keywords>

If I try to access https://podfetch.SERVER.COM/podcasts/99% Invisible/image.jpg on my browser I get a

This site can’t be reachedThe web page at https://podfetch.SERVER.COM/podcasts/99%%20Invisible/image.jpg might be temporarily down or it may have moved permanently to a new web address.
ERR_HTTP2_PROTOCOL_ERROR

Note the URL above is actually changed to https://podfetch.SERVER.COM/podcasts/99%%20Invisible/image.jpg

Now for the next podcast "Ask Noah"

<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
<channel>
<title>Ask Noah Show</title>
<link>https://podfetch.SERVER.COM/rss/5</link>
<description>The Ask Noah Show is a weekly talk radio show where we focus on Linux and Open Source technology. We invite the community to participate live on the air 1-855-450-6624. The show airs Tuesdays at 6pm CT on asknoahshow.com and at KEQQ 88.3 FM in Grand Forks ND. It's a free call 1-855-450-NOAH so join us and start on your way to owning your operating system, your software, and technology.</description>
<language>en-us</language>
<category>Technology</category>
<category>News</category>
<category>Education</category>
<itunes:author>Noah J. Chelliah</itunes:author>
<itunes:category text="Technology"/>
<itunes:category text="News"/>
<itunes:category text="Education"/>
<itunes:image href="https://podfetch.SERVER.COM/podcasts/Ask Noah Show/image.jpg"/>
<itunes:explicit>false</itunes:explicit>
<itunes:new-feed-url>https://podfetch.SERVER.COM/rss/5</itunes:new-feed-url>
<itunes:owner>
<itunes:name>Noah J. Chelliah</itunes:name>
<itunes:email>local@local.com</itunes:email>
</itunes:owner>
<itunes:summary>The Ask Noah Show is a weekly talk radio show where we focus on Linux and Open Source technology. We invite the community to participate live on the air 1-855-450-6624. The show airs Tuesdays at 6pm CT on asknoahshow.com and at KEQQ 88.3 FM in Grand Forks ND. It's a free call 1-855-450-NOAH so join us and start on your way to owning your operating system, your software, and technology.</itunes:summary>
<itunes:keywords>Technology,News,Education</itunes:keywords>

Using the URL https://podfetch.SERVER.COM/podcasts/Ask Noah Show/image.jpg this time just loads a malformed img thumbnail and going into the folder for this podcast and trying to load the image also doesn't work. Downloading the image manually and placing it in the podcast folder does resolve the issue on the webui.

In summary I'm not sure this is a singular issue, but more of a general thing where resolving thumbnails/downloading thumbails fails.

@arcoast
Copy link
Contributor Author

arcoast commented Jul 27, 2023

Have continued digging into this, managed to fix the issue with no thumbnails for the podcast by manually replacing image.jpg in the affected podcasts, this resolves the "All Subscriptions" page with thumbnails all displayed (after a browser refresh).

On the "Latest Episodes" however the thumbnails still aren't displayed presumedly as all the image.jpg files in the podcast subfolders are also not downloaded correctly. I'll have to wait to see if this issue is resolved when a new episode of one of the affected feeds comes out.

The podcast "99% Invisible" however I think is a completely different issue. Now, interestingly enough, this podcast broke Mazda car stereos (if I remember correctly it was due to the % symbol in the title.) so I tried the "Mazda Friendly" feed (See here for the episode) which unfortunately didn't resolve the issue. However although the thumbnail doesn't load like all the podcasts above, it's more complicated than that.

The podcast feed is added without error, but it's not possible to play a lot of the podcast episodes.

2023-07-27T09:36:42.482575117Z thread 'tokio-runtime-worker' panicked at 'failed to copy content: Custom { kind: Other, error: reqwest::Error { kind: Body, source: hyper::Error(Body, Custom { kind: UnexpectedEof, error: IncompleteBody }) } }', src/service/download_service.rs:90:47
2023-07-27T09:36:42.482599925Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2023-07-27T09:36:42.500354148Z thread 'actix-rt|system:0|arbiter:3' panicked at 'called `Result::unwrap()` on an `Err` value: JoinError::Panic(Id(699), ...)', src/service/rust_service.rs:190:22
2023-07-27T09:36:48.946129065Z 2023-07-27T09:36:48 ℹ - Refreshing podcast: 99% invisible
2023-07-27T09:36:52.044217789Z 2023-07-27T09:36:52 ℹ - Downloading podcast episode: 536- Nuts and Bolts
2023-07-27T09:36:52.049830641Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T09:36:52.970621076Z thread '<unnamed>' panicked at 'failed to copy content: Custom { kind: Other, error: reqwest::Error { kind: Body, source: hyper::Error(Body, Custom { kind: UnexpectedEof, error: IncompleteBody }) } }', src/service/download_service.rs:90:47

@SamTV12345
Copy link
Owner

image
image

As you can see it works without a problem. Can you replicate the issue and give me a step by step guide?

@arcoast
Copy link
Contributor Author

arcoast commented Jul 27, 2023

@SamTV12345 That's interesting, yeah I can definitely replicate it. Have nuked and paved a few times now to try and iron out issues.

EDIT: As for the step by step guide, it's essentially the docker-compose.yml and .env I posted in my first message above running behind Traefik.

Here's a log from when I've just added 99% Invisible using the iTunes podcast search facility tried to play the first episode. The icon still doesn't appear for me.

2023-07-27T10:03:10.794921977Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T10:03:11.207585741Z thread '<unnamed>' panicked at 'Error parsing date: ParseError(Impossible)', src/models/podcast_episode.rs:126:63
2023-07-27T11:55:40.003238543Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:55:53.901555546Z 2023-07-27T11:55:53 ℹ - Found podcast: https://itunes.apple.com/search?term=&term=99%25+Invisible&entity=podcast
2023-07-27T11:55:55.785692291Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:55:57.814538950Z 2023-07-27T11:55:57 ℹ - Downloading podcast episode: 546- The Country of the Blind
2023-07-27T11:55:57.820123074Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:55:58.938466920Z 2023-07-27T11:55:58 ℹ - Downloading podcast episode: 545- Shade Redux
2023-07-27T11:55:58.944078830Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:55:59.148782937Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:55:59.786879882Z 2023-07-27T11:55:59 ℹ - Downloading podcast episode: 544- Chick Tracts
2023-07-27T11:55:59.792522274Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:56:01.626089718Z 2023-07-27T11:56:01 ℹ - Downloading podcast episode: 543- In Proximity: Ryan Coogler and Roman Mars
2023-07-27T11:56:01.631725852Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:56:02.690502027Z 2023-07-27T11:56:02 ℹ - Downloading podcast episode: 542- Player Piano
2023-07-27T11:56:02.696091937Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:56:04.765672455Z 2023-07-27T11:56:04 ℹ - Downloading podcast episode: 541- The Frankfurt Kitchen
2023-07-27T11:56:04.771329439Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:56:05.655637901Z 2023-07-27T11:56:05 ℹ - Downloading podcast episode: 540- The Siren of Scrap Metal
2023-07-27T11:56:05.661262424Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:56:06.539646227Z 2023-07-27T11:56:06 ℹ - Downloading podcast episode: 539- Courtroom Sketch
2023-07-27T11:56:06.545300087Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:56:07.568479754Z 2023-07-27T11:56:07 ℹ - Downloading podcast episode: 415- Goodnight Nobody [rebroadcast]
2023-07-27T11:56:07.574109412Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:56:08.526446063Z 2023-07-27T11:56:08 ℹ - Downloading podcast episode: 538- Train Set: Track Three
2023-07-27T11:56:08.532036116Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:56:09.088527578Z 2023-07-27T11:56:09 ℹ - Downloading podcast episode: 537- Paved Paradise
2023-07-27T11:56:09.094115649Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:56:10.063507653Z 2023-07-27T11:56:10 ℹ - Downloading podcast episode: 536- Nuts and Bolts
2023-07-27T11:56:10.069130988Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:56:10.985230752Z 2023-07-27T11:56:10 ℹ - Downloading podcast episode: 535- Craptions
2023-07-27T11:56:10.990871600Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:56:11.887794652Z 2023-07-27T11:56:11 ℹ - Downloading podcast episode: 534- For Amusement Only (Free Replay)
2023-07-27T11:56:11.893502314Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:56:14.710465565Z 2023-07-27T11:56:14 ℹ - Downloading podcast episode: 533- Dear John and Roman
2023-07-27T11:56:14.716084004Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:56:16.129967367Z 2023-07-27T11:56:16 ℹ - Downloading podcast episode: 532- For a Dollar and a Dream
2023-07-27T11:56:16.135619418Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:56:17.050595294Z 2023-07-27T11:56:17 ℹ - Downloading podcast episode: 531- De Fiets Is Niets
2023-07-27T11:56:17.056319528Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:56:18.015101946Z 2023-07-27T11:56:18 ℹ - Downloading podcast episode: 530- The Panopticon Effect
2023-07-27T11:56:18.020703690Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:56:21.910595126Z 2023-07-27T11:56:21 ℹ - Downloading podcast episode: 529- The Wilderness Tool
2023-07-27T11:56:21.916073468Z Connecting to postgresql://podfetch:password@podfetch-postgres/podfetch
2023-07-27T11:56:23.255034343Z thread 'tokio-runtime-worker' panicked at 'failed to copy content: Custom { kind: Other, error: reqwest::Error { kind: Body, source: hyper::Error(Body, Custom { kind: UnexpectedEof, error: IncompleteBody }) } }', src/service/download_service.rs:90:47
2023-07-27T11:56:23.258713183Z thread 'actix-rt|system:0|arbiter:0' panicked at 'called `Result::unwrap()` on an `Err` value: JoinError::Panic(Id(127642), ...)', src/service/rust_service.rs:190:22

@arcoast
Copy link
Contributor Author

arcoast commented Jul 27, 2023

Also would you mind trying one of the other podcast feeds and seeing if you can replicate the lack of icons appearing?

@arcoast
Copy link
Contributor Author

arcoast commented Jul 27, 2023

OK, getting somewhere now. Removing Authelia & Traefik from the equation resolves the issues. Happy to try and work to get this resolved though, as I suspect as podfetch gains traction I'm not going to be the first person to hit this issue.

@SamTV12345
Copy link
Owner

Also would you mind trying one of the other podcast feeds and seeing if you can replicate the lack of icons appearing?

I tried it on a separate server and it did work. You also get some errors in the logs.

@SamTV12345
Copy link
Owner

OK, getting somewhere now. Removing Authelia & Traefik from the equation resolves the issues. Happy to try and work to get this resolved though, as I suspect as podfetch gains traction I'm not going to be the first person to hit this issue.

2023-07-27T11:56:23.255034343Z thread 'tokio-runtime-worker' panicked at 'failed to copy content: Custom { kind: Other, error: reqwest::Error { kind: Body, source: hyper::Error(Body, Custom { kind: UnexpectedEof, error: IncompleteBody }) } }', src/service/download_service.rs:90:47
That sounds like a connection error.

@arcoast
Copy link
Contributor Author

arcoast commented Jul 27, 2023

It's definitely something to do with Traefik. It all works as expected until I put it behind the Traefik reverse proxy.

So changing my .env from

SERVER_URL=https://podfetch.server.com/

to

SERVER_URL=http://192.168.0.250:8000

fixes all the issues.

My gut feeling is it's something to do with websockets, but I'm struggling to know where to go next with this.

@SamTV12345
Copy link
Owner

So your setup is Traefik -> PodFetch?
Is the SSL termination on Traefik?

@SamTV12345
Copy link
Owner

It's definitely something to do with Traefik. It all works as expected until I put it behind the Traefik reverse proxy.

So changing my .env from

SERVER_URL=https://podfetch.server.com/

to

SERVER_URL=http://192.168.0.250:8000

fixes all the issues.

My gut feeling is it's something to do with websockets, but I'm struggling to know where to go next with this.

If you set it to http PodFetch won't establish a secure websocket leading to mixed content which most browsers will block.

@arcoast
Copy link
Contributor Author

arcoast commented Jul 27, 2023

So your setup is Traefik -> PodFetch? Is the SSL termination on Traefik?

Yes, and Traefik is exposing only port 443 for SSL

@SamTV12345
Copy link
Owner

And you have Traefik set to route that traefik to http://podfetch-ip? Could you share your traefik config anonymized?

@arcoast
Copy link
Contributor Author

arcoast commented Jul 27, 2023

It's definitely something to do with Traefik. It all works as expected until I put it behind the Traefik reverse proxy.
So changing my .env from

SERVER_URL=https://podfetch.server.com/

to

SERVER_URL=http://192.168.0.250:8000

fixes all the issues.
My gut feeling is it's something to do with websockets, but I'm struggling to know where to go next with this.

If you set it to http PodFetch won't establish a secure websocket leading to mixed content which most browsers will block.

Using http://192.168.0.250:8000 everything works correctly, so if I'm correct in my understanding when I put Traefik in front my broswer is then blocking anything on the websocket which is served on http.

In that case, is there anyway to force podfetch is serve on https?

The alternative is to see if I can force a websocket http to https upgrade.

@arcoast
Copy link
Contributor Author

arcoast commented Jul 27, 2023

And you have Traefik set to route that traefik to http://podfetch-ip? Could you share your traefik config anonymized?

https://podfetch.server.com on port 443.

Yeah, I'll sanitise my config and post it here, gimme a few minutes.

@SamTV12345
Copy link
Owner

And you have Traefik set to route that traefik to http://podfetch-ip? Could you share your traefik config anonymized?

https://podfetch.server.com on port 443.

Yeah, I'll sanitise my config and post it here, gimme a few minutes.

Ah that's the problem. podfetch doesn't know anything about SSL. The SERVER_URL is the url that you type into the browser. Try http and maybe another port.

I'm just curious how you can do that config in Traefik as I want to move from Nginx Proxy Manger to Traefik as I added a DNS-0 challenge for my preferred Dyn DNS provider.

@arcoast
Copy link
Contributor Author

arcoast commented Jul 27, 2023

traefik.yaml

global:
  checkNewVersion: true
  sendAnonymousUsage: false

serversTransport:
  insecureSkipVerify: true

api:
  dashboard: true
  insecure: false

entryPoints:
  https:
    address: ":443"
    proxyProtocol:
      trustedIPs:
        - 192.168.0.0/16
    forwardedHeaders:
      trustedIPs:
        - 127.0.0.1/32
        - 192.168.0.0/16

    http:
      tls:
        certResolver: letsencrypt-dns
        domains:
          - main: 'server.com'
            sans:
              - '*.server.com'

providers:
  docker:
    endpoint: "tcp://docker-socket-proxy:2375"
    exposedByDefault: false
    defaultRule: "Host(`{{ index .Labels \"com.docker.compose.service\"}}.server.com`)"
    network: traefik
  file:
    directory: "/configs"
    watch: true

certificatesResolvers:

  letsencrypt-dns:
    acme:
      email: myemail@email.com
      storage: acme.json
      #caServer: "https://acme-staging-v02.api.letsencrypt.org/directory" #Uncomment for staging
      dnsChallenge:
        provider: cloudflare
        delayBeforeCheck: 20s
        resolvers:
          - "1.1.1.1:53"
          - "1.0.0.1:53"
        disablePropagationCheck: true

accessLog:
  filePath: "/logs/access.log"
  
  fields:
    headers:
      names:
        User-Agent: keep

  filters:
    statusCodes:
      - "400-499"
    retryAttempts: true

# By default, the level is set to ERROR, Set to  DEBUG, PANIC, FATAL, ERROR, WARN, and INFO.
log:
  level: ERROR

authelia-middleware.yaml

http:
  middlewares:
    authelia:
      forwardauth:
        address: http://authelia:9091/api/verify?rd=https://login.{{env "TRAEFIK_DOMAIN"}}/ # replace auth with your authelia container name
        trustForwardHeader: true
        authResponseHeaders:
          - Remote-User
          - Remote-Groups
          - Remote-Name
          - Remote-Email

security-middleware.yaml

http:
  middlewares:
    securityHeaders:
      headers:
        customResponseHeaders:
          X-Robots-Tag: "none,noarchive,nosnippet,notranslate,noimageindex"
          X-Forwarded-Proto: "https"
          server: ""
        customRequestHeaders:
          X-Forwarded-Proto: "https"
        sslProxyHeaders:
          X-Forwarded-Proto: "https"
        referrerPolicy: "same-origin"
        hostsProxyHeaders:
          - "X-Forwarded-Host"
        contentTypeNosniff: true
        browserXssFilter: true
        forceSTSHeader: true
        stsIncludeSubdomains: true
        stsSeconds: 63072000
        stsPreload: true

Then to run podfetch behind the Traefik reverse proxy I just run this compose file:

    podfetch:
        image: samuel19982/podfetch:postgres
        container_name: podfetch
        networks:
            - podfetch
            - traefik
        user: 99:100
        environment:
            - POLLING_INTERVAL=${POLLING_INTERVAL}
            - SERVER_URL=${SERVER_URL}
#            - GPODDER_INTEGRATION_ENABLED=${GPODDER_INTEGRATION_ENABLED}
            - PODINDEX_API_KEY=${PODINDEX_API_KEY}
            - PODINDEX_API_SECRET=${PODINDEX_API_SECRET}
            - DATABASE_URL=${DATABASE_URL}
            - DB_CONNECTIONS=${DB_CONNECTIONS}
        volumes:
            - ${PODCASTS}/new:/app/podcasts
            - ${CONFIG}/podfetch:/app/db
#        ports:
#            - 8000:8000
        restart: always
        labels:
            - "traefik.enable=true"
            - "traefik.http.routers.podfetch.middlewares=authelia@file, securityHeaders@file"

    podfetch-postgres:
        image: postgres
        container_name: podfetch-postgres
        networks:
            - podfetch
        environment:
            - POSTGRES_DB=${PODFETCH_POSTGRES_DB}
            - POSTGRES_USER=${PODFETCH_POSTGRES_USER}
            - POSTGRES_PASSWORD=${PODFETCH_POSTGRES_PASSWORD}
        volumes:
            - ${CONFIG}/podfetch-postgres:/var/lib/postgresql/data
#        ports:
#            - 5432:5432
        restart: unless-stopped

With this .env file

POLLING_INTERVAL=60
SERVER_URL=https://podfetch.server.com/
GPODDER_INTEGRATION_ENABLED=false
PODINDEX_API_KEY=API_KEY
PODINDEX_API_SECRET=API_SECRET
DATABASE_URL=postgresql://podfetch:password@podfetch-postgres/podfetch
DB_CONNECTIONS=10
PODFETCH_POSTGRES_DB=podfetch
PODFETCH_POSTGRES_USER=podfetch
PODFETCH_POSTGRES_PASSWORD=password

@SamTV12345
Copy link
Owner

Thanks for the detailed configuration. I'll try that.

@arcoast
Copy link
Contributor Author

arcoast commented Jul 27, 2023

I can't change my external domain to http well I could but I'd be unwilling to do so and open port 80 on my firewall.

As regards Traefik, I've never used NPM but have used Nginx for years, I migrated to Traefik a while ago and never looked back I love the fact I just need to add some docker labels to a service to reverse proxy it.

If you have an email I can ping you across a guide I wrote for a friend to get him up and running.

@SamTV12345
Copy link
Owner

Thanks you can contact me via samelus1998@outlook.de . I meant that the internal traefik inside the container network should be http. I'll try to replicate that scenario. Maybe I can find a configuration error. Or maybe try to go from the ip of the host and the port of the container rather than the docker network.

@arcoast
Copy link
Contributor Author

arcoast commented Jul 27, 2023

Thanks you can contact me via samelus1998@outlook.de . I meant that the internal traefik inside the container network should be http. I'll try to replicate that scenario. Maybe I can find a configuration error. Or maybe try to go from the ip of the host and the port of the container rather than the docker network.

Ah, gotcha, yeah it already is by default. If I have a container that communicates on https then I have to specify that in my traefik labels, if it is http then no extra config is required.

@arcoast
Copy link
Contributor Author

arcoast commented Jul 27, 2023

@SamTV12345 Have added you as a collaborator on my private repo. If anything isn't clear then feel free to open an issue.

@arcoast arcoast changed the title Icons not always displayed Some content not working when behind Traefik reverse proxy Jul 27, 2023
@arcoast
Copy link
Contributor Author

arcoast commented Jul 27, 2023

So have tried exposing port 8000 and applyng a file based config with Traefik using both:

SERVER_URL=https://podfetch.server.com/

and

SERVER_URL=http://192.168.0.250:8000
    podfetch:
        image: samuel19982/podfetch:postgres
        container_name: podfetch
        networks:
            - podfetch
            - traefik
        user: 99:100
        environment:
            - POLLING_INTERVAL=${POLLING_INTERVAL}
            - SERVER_URL=${SERVER_URL}
#            - GPODDER_INTEGRATION_ENABLED=${GPODDER_INTEGRATION_ENABLED}
            - PODINDEX_API_KEY=${PODINDEX_API_KEY}
            - PODINDEX_API_SECRET=${PODINDEX_API_SECRET}
            - DATABASE_URL=${DATABASE_URL}
            - DB_CONNECTIONS=${DB_CONNECTIONS}
        volumes:
            - ${PODCASTS}:/app/podcasts
            - ${CONFIG}/podfetch:/app/db
        ports:
            - 8000:8000
        restart: always
#        labels:
#            - "traefik.enable=true"
#            - "traefik.http.routers.podfetch.middlewares=authelia@file, podfetch@file, securityHeaders@file"
#            - "traefik.http.routers.podfetch.middlewares=authelia@file"
#            - "traefik.http.routers.podfetch.middlewares=securityHeaders@file"

Traefik dynamic file based config

http:
  routers:
    podfetch:
      entryPoints:
        - https
      rule: 'Host(`podfetch.{{env "TRAEFIK_DOMAIN"}}`)'
      service: podfetch
      middlewares:
        - "authelia@file"
        - "securityHeaders@file"
        - "podfetch@file"
#        - "authentik@file"

  services:
    podfetch:
      loadBalancer:
        servers:
          - url: http://192.168.0.250:8000

And tried applying a middleware to the config to upgrade any websocket connections but unfortunately not managed to solve this issue yet.

http:
  middlewares:
    podfetch:
      headers:
        customRequestHeaders:
          X-Forwarded-Proto: "https,wss"

My other middlewares for TRaefik are:

http:
  middlewares:
    securityHeaders:
      headers:
        customResponseHeaders:
          X-Robots-Tag: "none,noarchive,nosnippet,notranslate,noimageindex"
          X-Forwarded-Proto: "https"
          server: ""
        customRequestHeaders:
          X-Forwarded-Proto: "https"
        sslProxyHeaders:
          X-Forwarded-Proto: "https"
        referrerPolicy: "same-origin"
        hostsProxyHeaders:
          - "X-Forwarded-Host"
        contentTypeNosniff: true
        browserXssFilter: true
        forceSTSHeader: true
        stsIncludeSubdomains: true
        stsSeconds: 63072000
        stsPreload: true

and

http:
  middlewares:
    authelia:
      forwardauth:
        address: http://authelia:9091/api/verify?rd=https://login.{{env "TRAEFIK_DOMAIN"}}/ # replace auth with your authelia container name
        trustForwardHeader: true
        authResponseHeaders:
          - Remote-User
          - Remote-Groups
          - Remote-Name
          - Remote-Email

I've tried removing both the securityHeaders & authelia middleware which also doesn't affect the issue.

I'm assuming this is an issue trying to serve ws over https so in my head I can see two solutions:

  1. Upgrade ws to wss
  2. Provide an option to serve podfetch over https & wss so any connections are already secure before they hit the reverse proxy.

I may be completely off piste with all this though as I'm no webdev.

@SamTV12345
Copy link
Owner

@SamTV12345 Have added you as a collaborator on my private repo. If anything isn't clear then feel free to open an issue.

Thanks for the invite. That looks promising. I'll try to create a Traefik environment at the weekend and create (hopefully) a wiki entry for deploying PodFetch with Traefik.

@SamTV12345
Copy link
Owner

So have tried exposing port 8000 and applyng a file based config with Traefik using both:

SERVER_URL=https://podfetch.server.com/

and

SERVER_URL=http://192.168.0.250:8000
    podfetch:
        image: samuel19982/podfetch:postgres
        container_name: podfetch
        networks:
            - podfetch
            - traefik
        user: 99:100
        environment:
            - POLLING_INTERVAL=${POLLING_INTERVAL}
            - SERVER_URL=${SERVER_URL}
#            - GPODDER_INTEGRATION_ENABLED=${GPODDER_INTEGRATION_ENABLED}
            - PODINDEX_API_KEY=${PODINDEX_API_KEY}
            - PODINDEX_API_SECRET=${PODINDEX_API_SECRET}
            - DATABASE_URL=${DATABASE_URL}
            - DB_CONNECTIONS=${DB_CONNECTIONS}
        volumes:
            - ${PODCASTS}:/app/podcasts
            - ${CONFIG}/podfetch:/app/db
        ports:
            - 8000:8000
        restart: always
#        labels:
#            - "traefik.enable=true"
#            - "traefik.http.routers.podfetch.middlewares=authelia@file, podfetch@file, securityHeaders@file"
#            - "traefik.http.routers.podfetch.middlewares=authelia@file"
#            - "traefik.http.routers.podfetch.middlewares=securityHeaders@file"

Traefik dynamic file based config

http:
  routers:
    podfetch:
      entryPoints:
        - https
      rule: 'Host(`podfetch.{{env "TRAEFIK_DOMAIN"}}`)'
      service: podfetch
      middlewares:
        - "authelia@file"
        - "securityHeaders@file"
        - "podfetch@file"
#        - "authentik@file"

  services:
    podfetch:
      loadBalancer:
        servers:
          - url: http://192.168.0.250:8000

And tried applying a middleware to the config to upgrade any websocket connections but unfortunately not managed to solve this issue yet.

http:
  middlewares:
    podfetch:
      headers:
        customRequestHeaders:
          X-Forwarded-Proto: "https,wss"

My other middlewares for TRaefik are:

http:
  middlewares:
    securityHeaders:
      headers:
        customResponseHeaders:
          X-Robots-Tag: "none,noarchive,nosnippet,notranslate,noimageindex"
          X-Forwarded-Proto: "https"
          server: ""
        customRequestHeaders:
          X-Forwarded-Proto: "https"
        sslProxyHeaders:
          X-Forwarded-Proto: "https"
        referrerPolicy: "same-origin"
        hostsProxyHeaders:
          - "X-Forwarded-Host"
        contentTypeNosniff: true
        browserXssFilter: true
        forceSTSHeader: true
        stsIncludeSubdomains: true
        stsSeconds: 63072000
        stsPreload: true

and

http:
  middlewares:
    authelia:
      forwardauth:
        address: http://authelia:9091/api/verify?rd=https://login.{{env "TRAEFIK_DOMAIN"}}/ # replace auth with your authelia container name
        trustForwardHeader: true
        authResponseHeaders:
          - Remote-User
          - Remote-Groups
          - Remote-Name
          - Remote-Email

I've tried removing both the securityHeaders & authelia middleware which also doesn't affect the issue.

I'm assuming this is an issue trying to serve ws over https so in my head I can see two solutions:

  1. Upgrade ws to wss
  2. Provide an option to serve podfetch over https & wss so any connections are already secure before they hit the reverse proxy.

I may be completely off piste with all this though as I'm no webdev.

Thanks for trying some configs. I hope that https won't be needed at the PodFetch end. I moved PodFetch today to Cloudflare tunnels and that seems to work. So I still have hope that it could be a configuration issue 🤞 .

@arcoast
Copy link
Contributor Author

arcoast commented Jul 28, 2023

I'm on holiday for a week so I'll probably not get the chance to do much for a while, but if it's ok with you I'd like to keep trying to get it working behind traefik and I'll post any findings I make so if anyone else comes along with a similar issue they can chip in.

@SamTV12345
Copy link
Owner

I added a sample configuration here: https://github.com/SamTV12345/PodFetch/tree/feature/terraform/docs/traefik . Next I'll try it with https but so far it works without a problem with http via Traefik.

@arcoast
Copy link
Contributor Author

arcoast commented Jul 31, 2023

That link doesn't work, but I took a look at the commit. I suspect it is an issue with mixed http/https content. Interestingly there's another new podcast app and reading their docs, whilst I don't exactly understand it all, it involves a proxy for images/audio files to avoid CORS issues https://www.pinepods.online/docs/intro#proxy-info

I wonder if that's the issue here, which may explain why you're finding it's working fine over http.

@SamTV12345
Copy link
Owner

That link doesn't work, but I took a look at the commit. I suspect it is an issue with mixed http/https content. Interestingly there's another new podcast app and reading their docs, whilst I don't exactly understand it all, it involves a proxy for images/audio files to avoid CORS issues https://www.pinepods.online/docs/intro#proxy-info

I wonder if that's the issue here, which may explain why you're finding it's working fine over http.

I proxy only the audio which can definteley cause issues with cors. I haven't found any cors issues with images. I am currently working on the SSL config in my homelab with Traefik. Maybe then I can find an error.

@SamTV12345
Copy link
Owner

I added my traefik yaml.

@arcoast
Copy link
Contributor Author

arcoast commented Aug 4, 2023

That's the same config as I have albeit in yaml form. Just to help debugging I used the yaml form:

http:
  routers:
    podfetch:
      entryPoints:
        - https
      rule: 'Host(`podfetch.{{env "TRAEFIK_DOMAIN"}}`)'
      service: podfetch

  services:
    podfetch:
      loadBalancer:
        servers:
          - url: http://x.x.x.x:8000

Still having the issues I described originally.

Struggling to see what I'm missing here.

@SamTV12345
Copy link
Owner

Ok. I'll try to create a simple docker compose with Traefik and PodFetch tomorrow. Maybe that will work.

@arcoast
Copy link
Contributor Author

arcoast commented Aug 4, 2023

I'm getting some browser console errors when trying to access over the reverse proxy.

My SERVER_URL variable is set:

SERVER_URL=https://podfetch.server.tld/

and if I run it without the Traefik reverse proxy with the SERVER_URL=http://x.x.x.x:8000 then everything works as expected.

Image

@helmut72
Copy link

helmut72 commented Aug 6, 2023

SERVER_URL=https://podfetch.server.com/

to

SERVER_URL=http://192.168.0.250:8000

Do you have tried it without the slash, because your other URL is also without a slash?

SERVER_URL=https://podfetch.server.com

@SamTV12345
Copy link
Owner

@arcoast Sorry I was busy this weekend. I'll try to reproduce it on Tuesday.

@arcoast
Copy link
Contributor Author

arcoast commented Aug 8, 2023

No worries, life gotta come first!

@arcoast
Copy link
Contributor Author

arcoast commented Aug 8, 2023

SERVER_URL=https://podfetch.server.com/

to

SERVER_URL=http://192.168.0.250:8000

Do you have tried it without the slash, because your other URL is also without a slash?

SERVER_URL=https://podfetch.server.com

Hi @helmut72 , yeah I've tried all combinations with no difference in observed behaviour, but thanks for taking a look and making suggestions!

@SamTV12345
Copy link
Owner

SERVER_URL=https://podfetch.server.com/

to

SERVER_URL=http://192.168.0.250:8000

Do you have tried it without the slash, because your other URL is also without a slash?

SERVER_URL=https://podfetch.server.com

Hi @helmut72 , yeah I've tried all combinations with no difference in observed behaviour, but thanks for taking a look and making suggestions!

It should not matter. I always add a slash to the url.

@SamTV12345
Copy link
Owner

There is a stackoverflow about this http2 error. https://stackoverflow.com/questions/67911570/failed-to-load-resource-neterr-http2-protocol-error-for-react-app-after-upg Did you use multiple platforms/mobile phones?

@SamTV12345
Copy link
Owner

Or try this dns provider first: https://ipv64.net/account . It is completely free for up to 3 main domains and has unlimited subdomain support. Then you should be able to use my setup. You might need to delete only the cloudflare domain and keep the ipv64 domain.

@arcoast
Copy link
Contributor Author

arcoast commented Aug 9, 2023

phones

Yes I did, tested on Brave browser on both Manjaro KDE and Android and also used Firefox on both platforms too.

I'll do some more testing again and see if my wife will let me borrow her Windows machine as I can test on that with Chrome, Edge & Firefox as well.

@arcoast
Copy link
Contributor Author

arcoast commented Aug 9, 2023

Or try this dns provider first: https://ipv64.net/account . It is completely free for up to 3 main domains and has unlimited subdomain support. Then you should be able to use my setup. You might need to delete only the cloudflare domain and keep the ipv64 domain.

Using terraform? Currently I have split DNS so any request from my LAN to *.server.com gets routed to the LAN IP of my docker host machine on port 443 which is Traefik.

I have tried using my 4G/LTE on Android to rule out any wacky issues with DNS.

I'd have to learn terraform to try it, I'm not against the idea but it'll take me some time.

If you want me to try a docker compose stack that would be much easier.

@arcoast
Copy link
Contributor Author

arcoast commented Aug 10, 2023

So, delved into this again and got a friend to test this on his machine to see if it's reproducible and he was able to do so and also provided some really useful insights. I thought given that, it would be useful to post a detailed explanation of the issue we're seeing.

First of all, for ease of testing I'm using the SQlite build, but I'm able to reproduce it exactly with postgres too.

First of all here's my docker-compose.yml

version: '3.9'

networks:
    traefik:
        external: false
        name: traefik

services:
    podfetch:
        image: samuel19982/podfetch:latest
        container_name: podfetch
        networks:
            - traefik
        user: ${UID:-99}:${GID:-100}
        ports:
            - 8000:8000
        volumes:
            - ${CONFIG}/podfetch-sql/podcasts:/app/podcasts
            - ${CONFIG}/podfetch-sql/db:/app/db
        environment:
            - POLLING_INTERVAL=60
            - SERVER_URL=https://podfetch.${TRAEFIK_DOMAIN}/
        labels:
            - "traefik.enable=true"
            - "traefik.docker.network=traefik"
            - "traefik.http.routers.podfetch.entrypoints=https"
            - "traefik.http.routers.podfetch.rule=Host(`podfetch.${TRAEFIK_DOMAIN}`)"
            - "traefik.http.services.podfetch.loadbalancer.server.port=8000"

My .env file:

CONFIG=/mnt/user/appdata
TRAEFIK_DOMAIN=server.com

Now once this is installed. Access the podfetch instance at https://podfetch.server.com

Go to All Subscriptions and add a new podcast and add 99% Invisible and you should find that although the podcast is added, the thumbnail for this is missing.

Using F12 to open the browser console (Either Firefox or Chrome based browser doesn't matter) and it shows a ERR_HTTP2_PROTOCOL_ERROR

The URL of the missing thumbnail is:

https://podfetch.server.com/podcasts/99%%20Invisible/image.jpg

and trying to load this directly into a browser shows

This site can’t be reached The web page at https://podfetch.server.com/podcasts/99%%20Invisible/image.jpg might be temporarily down or it may have moved permanently to a new web address.
ERR_HTTP2_PROTOCOL_ERROR

Now reading about URL encoding specifically the line about the Percent character:

Because the percent character ( % ) serves as the indicator for percent-encoded octets, it must be percent-encoded as %25 for that octet to be used as data within a URI.

Which means if you change the above URL which isn't working.

https://podfetch.server.com/podcasts/99%%20Invisible/image.jpg

to

https://podfetch.server.com/podcasts/99%25%20Invisible/image.jpg

means the thumbnail loads.

Now I also noticed that some podcast episodes from 99% Invisible also wouldn't play in the browser which caused me some confusion, but I think I've figured it out. It only seems to be the podcast episodes that have been downloaded. If I attempt to stream a 99% Invisible podcast episode that isn't being cached locally on my server, it plays fine with a URL like this: (These episodes also correctly display the thumbnail too.)

https://podfetch.server.com/proxy/podcast?episodeId=9a4a85da-ffc2-4de0-b525-525bf647325b

However once I download the episode to my server and use ctrl + F5 then attempt to play it I get no playback as it's trying to play from the URL:

https://podfetch.server.com/podcasts/99%%20Invisible/'546-%20The%20Country%20of%20the%20Blind'/podcast.mp3

However changing this URL by adding in the missing 25 to:

https://podfetch.server.com/podcasts/99%25%20Invisible/'546-%20The%20Country%20of%20the%20Blind'/podcast.mp3

and the MP3 will load correctly.

I will need to do some more experimenting, as I had some less significant issues with other podcasts and images, but I haven't looked into it sufficiently yet to work it out.

I hope this gives a few more clues on getting to the bottom of things.

@arcoast
Copy link
Contributor Author

arcoast commented Aug 11, 2023

So following on from my post yesterday, I've now experimented with running podfetch via http://<IP>:<PORT> and it's quite interesting.

Other than http://<IP>:<PORT> being replaced by https://podfetch.server.com the URLs are otherwise identical and here's where I think it gets interesting, without the reverse proxy either of the URLS I was experimenting with will work.

So for an image file like above:

http://<IP>:<PORT>/podcasts/99%%20Invisible/image.jpg will work, but it will also work if I change the URL to:
http://<IP>:<PORT>/podcasts/99%25%20Invisible/image.jpg

And the same phenomenon can be observed for the mp3 files

http://<IP>:<PORT>/podcasts/99%%20Invisible/'546-%20The%20Country%20of%20the%20Blind'/podcast.mp3 will work, but it will also work if I change the URL to:

http://<IP>:<PORT>/podcasts/99%25%20Invisible/'546-%20The%20Country%20of%20the%20Blind'/podcast.mp3

In summary I think if the URL encoding used in Podfetch is changed to the format in the second type where the % symbol is encoded as %25 I think this issue would be resolved.

@nomandera
Copy link

nomandera commented Aug 12, 2023

I had a quick look at this as I can replicate in my setup.

From:

https://github.com/SamTV12345/PodFetch/blob/main/ui/src/utils/Utilities.tsx#L93

It appears that a bespoke URL encoding methodology is employed, cherry picking just two characters which often results in a URL that is a mix of encodied characters and not. This will have unpredictable results depending on the client or proxy and likely explains a lot of these weird symptoms.

To avoid edge cases like this and handle internationalisation a URL encoder library should be called instead.

@SamTV12345
Copy link
Owner

I had a quick look at this as I can replicate in my setup.

From:

https://github.com/SamTV12345/PodFetch/blob/main/ui/src/utils/Utilities.tsx#L93

It appears that a bespoke URL encoding methodology is employed, cherry picking just two characters which often results in a URL that is a mix of encodied characters and not. This will have unpredictable results depending on the client or proxy and likely explains a lot of these weird symptoms.

To avoid edge cases like this and handle internationalisation a URL encoder library should be called instead.

@nomandera @helmut72 @arcoast I may have found a fix. Could you please try the latest dev images?

@arcoast
Copy link
Contributor Author

arcoast commented Aug 12, 2023

@SamTV12345

Just tried the latest dev image with this commit

It's improved things, but not fixed everything with regard to 99% Invisible.

The podcast streams are now playing even when cached locally with a URL like this:
https://podfetch.server.com/podcasts/99%25%20Invisible/%27548-%20Trail%20Mix%27/podcast.mp3

However the URLs to call image.jpg still don't work once an episode has been cached locally and the browser refreshed.

@SamTV12345
Copy link
Owner

So the images are currently only missing but the podcast plays just fine?

@arcoast
Copy link
Contributor Author

arcoast commented Aug 12, 2023

So the images are currently only missing but the podcast plays just fine?

Yes, that does appear to be the case.

@arcoast
Copy link
Contributor Author

arcoast commented Aug 12, 2023

It's a little more subtle that that though, as a browser refresh can cause images that were working to disappear and I think it's because once an image is cached locally it stops working.

@SamTV12345
Copy link
Owner

Thanks. I'll try to investigate why the images are not working but the podcast url does. They both have the same method applied.

@helmut72
Copy link

@helmut72 I may have found a fix. Could you please try the latest dev images?

I just mention the differences, one with one without slahs. But I don't use Traefik. Sorry.

@SamTV12345
Copy link
Owner

SamTV12345 commented Aug 25, 2023

Awesome I could finally replicate the issue. Now I can test that bug.

@arcoast
Copy link
Contributor Author

arcoast commented Aug 26, 2023

Awesome I could finally replicate the issue. Now I can test that bug.

That's great, there's been times where I've started to doubt myself here and I've racked my brains trying to work out where I've been going wrong, so that's a relief to hear!

Let me know if you want any testing or info and I'm more than happy to help however I can.

@SamTV12345
Copy link
Owner

@arcoast I think I solved the problem completely. Could you please checkout the dev-urlencoding tag? Try to download all sorts of podcasts and check if you can still play the episodes back.

@arcoast
Copy link
Contributor Author

arcoast commented Aug 26, 2023

@SamTV12345 Yep, pulled the dev-urlencoding tag and can confirm that the issue does indeed seem to be fixed from what I can tell.

99% Invisible is working perfectly and the thumbnails for other podcasts are now appearing correctly. (I did wonder if that was a separate issue entirely recently, but regardless it seems to be resolved)

Can I just say a big "Thank You" for your efforts to resolve this, I know it's been an epic issue in length, it's very much appreciated.

I did look the other day for a donation link, but I can't see one anywhere, as I definitely owe you a beer!

@SamTV12345
Copy link
Owner

You're welcome. That was a lot of work and debug. But I am happy that this is finally solved. I'll merge the branch into main so the image should be there in 10 minutes if my Mac mini doesn't let me down 😄.

I unfortunately live in Germany where tax regulations are really strict. I did experiment with GitHub sponsors the other day but it doesn't seem really worth the hassle.
I either have to apply for an organization that itself takes a share of the money or do this on my own and create a company.

So yeah I am also fine with not taking any money. I am always happy if someone gives me a feedback - either positive or negative. So have fun with PodFetch 😃 .

@arcoast
Copy link
Contributor Author

arcoast commented Aug 26, 2023

Closed by #263

Confirmed as working with postgres tag.

@arcoast arcoast closed this as completed Aug 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants