[GH-ISSUE #939] Playback fails with 401 Unauthorized error #605

Closed
opened 2026-02-26 02:33:41 +03:00 by kerem · 2 comments
Owner

Originally created by @p4t5h3 on GitHub (Mar 24, 2019).
Original GitHub issue: https://github.com/koel/koel/issues/939

Hey, thanks for contributing to Koel! To save time for both of us, please make sure these checkboxes are checked before submitting the issue:

  • You have read and followed closely the Wiki, Upgrade Guide, as well as Troubleshooting
  • The issue has not been reported before
  • This is not a "how to install on Windows" or "why is my npm messed up" question
  • You're a cool person

All checked? Now also make sure your issue

  • Is associated with a version. Or better yet, a commit.
  • Is as detailed as possible (ahem... OS, browser, steps to reproduce, maybe?)
  • Includes the error output if it's a bug/error report ("Whoops!" is not very helpful, you know)
  • Is in English, 因为我不说中文。

I freshly installed Koel v3.7.2 via Git on Ubuntu Server 18.04 LTS with a MySQL and nginx set up. I can login and see a test album I added to my media directory. When trying to play it, I get the following warning and error in Firefox (I replaced the domain part on purpose, by the way):

HTTP load failed with status 401. Load of media resource https://example.org/api/fe6d5c78314790ac81183ee0c1aeba92/play?jwt-token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEsImlzcyI6Imh0dHBzOi8va29lbC5wZXRlcnRob21hc2hvcm4uaW5mby9hcGkvbWUiLCJpYXQiOjE1NTM0NDk3ODMsImV4cCI6MTU1NDA1NDU4MywibmJmIjoxNTUzNDQ5NzgzLCJqdGkiOiI4ZHNCd0dCazdWWDI4NEd0In0.m6HxMmJtkIUVnZaAn7dtw9PSEyTO0marMEfhHFHyusQ failed.
NotSupportedError: The media resource indicated by the src attribute or assigned media provider object was not suitable.
  • I originally detected this in Safari but wanted to rule out it is a browser issue.
  • It is reproducible in Chrome, too.
  • Logging out and back in does not resolve this issue (of a possibly outdated JWT)
  • laravel.log is not revealing any insights. Neither does the PHP FPM or nginx error log. The nginx access log just lists the request with a 401 response code.
  • The album is ALAC but I reproduced this problem with a standard MP3.
  • Having the STREAMING_METHOD set to php or x-accel-redirect does not make a difference.
  • I doubt it is related to the JWT as /api/data with all the metadata is loaded successfully.

What else could be wrong? 🤔 I did not understand the X-Media-Root thing from the nginx sample configuration which I tried to merge with the default site and recommended Laravel configuration. This is an excerpt in which I replaced the media_path setting variable from upstream with the media root path:

location /media/ {
        internal;
        alias /var/www/music;
        access_log /var/log/nginx/koel.access.log;
        error_log  /var/log/nginx/koel.error.log;
}

The directory has the same owner and group (www-data:www-data) as the app root next to it. I am running out of ideas.

Originally created by @p4t5h3 on GitHub (Mar 24, 2019). Original GitHub issue: https://github.com/koel/koel/issues/939 Hey, thanks for contributing to Koel! To save time for both of us, please make sure these checkboxes are checked before submitting the issue: - [X] You have read and followed closely the [Wiki](https://koel.phanan.net/docs), [Upgrade Guide](https://github.com/phanan/koel/releases), as well as [Troubleshooting](https://koel.phanan.net/docs/#/troubleshooting) - [X] The issue has not been reported before - [X] This is not a "how to install on Windows" or "why is my npm messed up" question - [X] You're a cool person All checked? Now also make sure your issue - [X] Is associated with a version. Or better yet, a commit. - [X] Is as detailed as possible (ahem... OS, browser, steps to reproduce, maybe?) - [X] Includes the error output if it's a bug/error report ("Whoops!" is not very helpful, you know) - [X] Is in English, 因为我不说中文。 ---- I freshly installed Koel v3.7.2 via Git on Ubuntu Server 18.04 LTS with a MySQL and nginx set up. I can login and see a test album I added to my media directory. When trying to play it, I get the following warning and error in Firefox (I replaced the domain part on purpose, by the way): HTTP load failed with status 401. Load of media resource https://example.org/api/fe6d5c78314790ac81183ee0c1aeba92/play?jwt-token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEsImlzcyI6Imh0dHBzOi8va29lbC5wZXRlcnRob21hc2hvcm4uaW5mby9hcGkvbWUiLCJpYXQiOjE1NTM0NDk3ODMsImV4cCI6MTU1NDA1NDU4MywibmJmIjoxNTUzNDQ5NzgzLCJqdGkiOiI4ZHNCd0dCazdWWDI4NEd0In0.m6HxMmJtkIUVnZaAn7dtw9PSEyTO0marMEfhHFHyusQ failed. NotSupportedError: The media resource indicated by the src attribute or assigned media provider object was not suitable. * I originally detected this in Safari but wanted to rule out it is a browser issue. * It is reproducible in Chrome, too. * Logging out and back in does not resolve this issue (of a possibly outdated JWT) * `laravel.log` is not revealing any insights. Neither does the PHP FPM or nginx error log. The nginx access log just lists the request with a 401 response code. * The album is ALAC but I reproduced this problem with a standard MP3. * Having the `STREAMING_METHOD` set to `php` or `x-accel-redirect` does not make a difference. * I doubt it is related to the JWT as `/api/data` with all the metadata is loaded successfully. What else could be wrong? 🤔 I did not understand the `X-Media-Root` thing from the [nginx sample configuration](https://github.com/phanan/koel/blob/master/nginx.conf.example) which I tried to merge with the default site and recommended Laravel configuration. This is an excerpt in which I replaced the media_path setting variable from upstream with the media root path: location /media/ { internal; alias /var/www/music; access_log /var/log/nginx/koel.access.log; error_log /var/log/nginx/koel.error.log; } The directory has the same owner and group (`www-data:www-data`) as the app root next to it. I am running out of ideas.
kerem closed this issue 2026-02-26 02:33:41 +03:00
Author
Owner

@phanan commented on GitHub (Mar 25, 2019):

You're not supposed to set/change the alias configuration. Just leave it as-is ($upstream_http_x_media_root) and try again.

<!-- gh-comment-id:476135439 --> @phanan commented on GitHub (Mar 25, 2019): You're not supposed to set/change the `alias` configuration. Just leave it as-is (`$upstream_http_x_media_root`) and try again.
Author
Owner

@p4t5h3 commented on GitHub (Mar 25, 2019):

That detail did not make the difference. However I had a fresh attempt today, took the example configuration as it is and adjusted only the server_name and fastcgi_pass and now it works. So my nginx configuration was the culprit. Possibly because I set up Certbot for Let's Encrypt first based on the default configuration mixed with the recommendations for Laravel.

<!-- gh-comment-id:476379300 --> @p4t5h3 commented on GitHub (Mar 25, 2019): That detail did not make the difference. However I had a fresh attempt today, took the example configuration as it is and adjusted only the `server_name` and `fastcgi_pass` and now it works. So my nginx configuration was the culprit. Possibly because I set up Certbot for Let's Encrypt first based on the default configuration mixed with the recommendations for Laravel.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/koel-koel#605
No description provided.