[GH-ISSUE #162] Music not playing with x-sendfile option #112

Closed
opened 2026-02-26 02:32:10 +03:00 by kerem · 16 comments
Owner

Originally created by @ronilaukkarinen on GitHub (Dec 29, 2015).
Original GitHub issue: https://github.com/koel/koel/issues/162

For some reason I cannot play anything with STREAMING_METHOD=x-sendfile.

My httpd.conf part:

LoadModule xsendfile_module   modules/mod_xsendfile.so

<IfModule xsendfile_module>
  XSendFile on
  XSendFilePath /var/www/html/koel
</IfModule>

Google Chrome console:

GET http://koel.myserver.xx/api/31ead2f07729e0d18ec5638fe6dd2662/play 404 (Not Found)ie @ vendors-99cbf2751a.js:1t.default.play @ main-aabff23d8c.js:14(anonymous function) @ main-aabff23d8c.js:14e @ main-aabff23d8c.js:7

With STREAMING_METHOD=php everything plays perfectly well. I'm using the latest 1.1.2.

Originally created by @ronilaukkarinen on GitHub (Dec 29, 2015). Original GitHub issue: https://github.com/koel/koel/issues/162 For some reason I cannot play anything with `STREAMING_METHOD=x-sendfile`. My httpd.conf part: ``` LoadModule xsendfile_module modules/mod_xsendfile.so <IfModule xsendfile_module> XSendFile on XSendFilePath /var/www/html/koel </IfModule> ``` Google Chrome console: ``` GET http://koel.myserver.xx/api/31ead2f07729e0d18ec5638fe6dd2662/play 404 (Not Found)ie @ vendors-99cbf2751a.js:1t.default.play @ main-aabff23d8c.js:14(anonymous function) @ main-aabff23d8c.js:14e @ main-aabff23d8c.js:7 ``` With `STREAMING_METHOD=php` everything plays perfectly well. I'm using the latest 1.1.2.
kerem closed this issue 2026-02-26 02:32:10 +03:00
Author
Owner

@phanan commented on GitHub (Dec 30, 2015):

Should be <IfModule mod_xsendfile.c> instead.

<!-- gh-comment-id:167922042 --> @phanan commented on GitHub (Dec 30, 2015): Should be `<IfModule mod_xsendfile.c>` instead.
Author
Owner

@ronilaukkarinen commented on GitHub (Dec 30, 2015):

This should be fixed in the Wiki?

<!-- gh-comment-id:167970016 --> @ronilaukkarinen commented on GitHub (Dec 30, 2015): This should be fixed in the Wiki?
Author
Owner

@ronilaukkarinen commented on GitHub (Dec 30, 2015):

Corrected my httpd.conf and restarted apache. Still geting the same error. Should I recompile koel after this? That module should be OK, I don't get any errors on apache's side.

<!-- gh-comment-id:167972435 --> @ronilaukkarinen commented on GitHub (Dec 30, 2015): Corrected my httpd.conf and restarted apache. Still geting the same error. Should I recompile koel after this? That module should be OK, I don't get any errors on apache's side.
Author
Owner

@phanan commented on GitHub (Dec 30, 2015):

I can't recall documenting this in wiki? Koel doesnt need to be recompiled, either.

<!-- gh-comment-id:167975368 --> @phanan commented on GitHub (Dec 30, 2015): I can't recall documenting this in wiki? Koel doesnt need to be recompiled, either.
Author
Owner

@ronilaukkarinen commented on GitHub (Dec 30, 2015):

@phanan It is, here. I don't get why it doesn't work. Is there true advantages in x-sendfile, faster perhaps? I'm forced to use php for now because it just works.

<!-- gh-comment-id:168037687 --> @ronilaukkarinen commented on GitHub (Dec 30, 2015): @phanan It is, [here](https://github.com/phanan/koel/wiki#streaming-music). I don't get why it doesn't work. Is there true advantages in x-sendfile, faster perhaps? I'm forced to use php for now because it just works.
Author
Owner

@phanan commented on GitHub (Dec 31, 2015):

Oops. Thanks for pointing it out.

I don't get why it doesn't work

Check the XSendFilePath variable maybe? I'd even remove the
directive, just to make sure.

Is there true advantages in x-sendfile, faster perhaps?

Yes.

On Thu, Dec 31, 2015 at 1:20 AM, Roni Laukkarinen notifications@github.com
wrote:

@phanan https://github.com/phanan It is, here
https://github.com/phanan/koel/wiki#streaming-music. I don't get why it
doesn't work. Is there true advantages in x-sendfile, faster perhaps? I'm
forced to use php for now because it just works.


Reply to this email directly or view it on GitHub
https://github.com/phanan/koel/issues/162#issuecomment-168037687.

<!-- gh-comment-id:168172194 --> @phanan commented on GitHub (Dec 31, 2015): Oops. Thanks for pointing it out. > I don't get why it doesn't work Check the XSendFilePath variable maybe? I'd even remove the <IfModule> directive, just to make sure. > Is there true advantages in x-sendfile, faster perhaps? Yes. On Thu, Dec 31, 2015 at 1:20 AM, Roni Laukkarinen notifications@github.com wrote: > @phanan https://github.com/phanan It is, here > https://github.com/phanan/koel/wiki#streaming-music. I don't get why it > doesn't work. Is there true advantages in x-sendfile, faster perhaps? I'm > forced to use php for now because it just works. > > — > Reply to this email directly or view it on GitHub > https://github.com/phanan/koel/issues/162#issuecomment-168037687.
Author
Owner

@ronilaukkarinen commented on GitHub (Jan 22, 2016):

I tested this again without . It seems the only way to get this to work is to add XSendFilePath /, not XSendFilePath /var/www or XSendFilePath /var/www/html/koel, because for some reason it won't find /api if set that way. Is setting XSendFilePath / very safe?

<!-- gh-comment-id:173842030 --> @ronilaukkarinen commented on GitHub (Jan 22, 2016): I tested this again without <IfModule>. It seems the only way to get this to work is to add `XSendFilePath /`, not `XSendFilePath /var/www` or `XSendFilePath /var/www/html/koel`, because for some reason it won't find /api if set that way. Is setting `XSendFilePath /` very safe?
Author
Owner

@triDcontrols commented on GitHub (Jul 21, 2017):

@ronilaukkarinen What prompted you to switch to x-sendfile? I'm having an issue with the slow responsiveness of the Koel UI and music stuttering in mobile chrome browser. Wanting to try x-sendfile but in the same boat as you as far as security is concerned, leaving Xsendfile to /.

<!-- gh-comment-id:317113494 --> @triDcontrols commented on GitHub (Jul 21, 2017): @ronilaukkarinen What prompted you to switch to x-sendfile? I'm having an issue with the slow responsiveness of the Koel UI and music stuttering in mobile chrome browser. Wanting to try x-sendfile but in the same boat as you as far as security is concerned, leaving Xsendfile to /.
Author
Owner

@ronilaukkarinen commented on GitHub (Jul 26, 2017):

@tridiumcontrols Tried it out based on the docs (it's supposed to be faster) and instructions @phanan gave me (two comments up), nothing else particular prompted me to the 'switch'.

<!-- gh-comment-id:318002694 --> @ronilaukkarinen commented on GitHub (Jul 26, 2017): @tridiumcontrols Tried it out based on the docs (it's supposed to be faster) and instructions @phanan gave me (two comments up), nothing else particular prompted me to the 'switch'.
Author
Owner

@Sp1l commented on GitHub (Jun 4, 2024):

I tested this again without . It seems the only way to get this to work is to add XSendFilePath /, not XSendFilePath /var/www or XSendFilePath /var/www/html/koel, because for some reason it won't find /api if set that way. Is setting XSendFilePath / very safe?

Not sure, but that would allow an attacker to read any file from your filesystem.

You can achieve the same without mod_xsendfile:

RewriteCond "%{REQUEST_URI}" "^/play/"
RewriteCond "%{HTTP:x-sendfile}" "^/full/path/like/MEDIA_PATH"
RewriteRule ^.*$ "%{HTTP:x-sendfile}" [L]
<!-- gh-comment-id:2146913321 --> @Sp1l commented on GitHub (Jun 4, 2024): > I tested this again without . It seems the only way to get this to work is to add `XSendFilePath /`, not `XSendFilePath /var/www` or `XSendFilePath /var/www/html/koel`, because for some reason it won't find /api if set that way. Is setting `XSendFilePath /` very safe? Not sure, but that would allow an attacker to read any file from your filesystem. You can achieve the same without mod_xsendfile: ``` RewriteCond "%{REQUEST_URI}" "^/play/" RewriteCond "%{HTTP:x-sendfile}" "^/full/path/like/MEDIA_PATH" RewriteRule ^.*$ "%{HTTP:x-sendfile}" [L] ```
Author
Owner

@phanan commented on GitHub (Jun 4, 2024):

@Sp1l When you say "You can achieve the same without mod_xsendfile," do you mean the streaming will work exactly like with the module without the need to install it?

<!-- gh-comment-id:2147043676 --> @phanan commented on GitHub (Jun 4, 2024): @Sp1l When you say "You can achieve the same without mod_xsendfile," do you mean the streaming will work exactly like with the module without the need to install it?
Author
Owner

@Sp1l commented on GitHub (Jun 4, 2024):

@Sp1l When you say "You can achieve the same without mod_xsendfile," do you mean the streaming will work exactly like with the module without the need to install it?

Scrap all of it, that's not what it does.

<!-- gh-comment-id:2147123477 --> @Sp1l commented on GitHub (Jun 4, 2024): > @Sp1l When you say "You can achieve the same without mod_xsendfile," do you mean the streaming will work exactly like with the module without the need to install it? Scrap all of it, that's not what it does.
Author
Owner

@phanan commented on GitHub (Jun 4, 2024):

TIL, thanks! I'll give it a go and update the docs for v7, which is coming very close :)

<!-- gh-comment-id:2147128968 --> @phanan commented on GitHub (Jun 4, 2024): TIL, thanks! I'll give it a go and update the docs for v7, which is coming very close :)
Author
Owner

@Sp1l commented on GitHub (Jun 4, 2024):

Define MEDIA_PATH "/full/path/to/your/MEDIA_PATH"

RewriteCond "%{REQUEST_URI}" "^/play/"
RewriteCond "%{HTTP:x-sendfile}" "^${MEDIA_PATH}"
RewriteRule ^.*$ "%{HTTP:x-sendfile}" [L]

<Directory "${MEDIA_PATH}">
    Options FollowSymlinks
    Require all granted
</Directory>

TIL, thanks! I'll give it a go and update the docs for v7, which is coming very close :)

Sorry... My bad. The x-sendfile is in the RESPONSE, not in the request

<!-- gh-comment-id:2147155975 --> @Sp1l commented on GitHub (Jun 4, 2024): ``` Define MEDIA_PATH "/full/path/to/your/MEDIA_PATH" RewriteCond "%{REQUEST_URI}" "^/play/" RewriteCond "%{HTTP:x-sendfile}" "^${MEDIA_PATH}" RewriteRule ^.*$ "%{HTTP:x-sendfile}" [L] <Directory "${MEDIA_PATH}"> Options FollowSymlinks Require all granted </Directory> ``` > TIL, thanks! I'll give it a go and update the docs for v7, which is coming very close :) Sorry... My bad. The x-sendfile is in the RESPONSE, not in the request
Author
Owner

@phanan commented on GitHub (Jun 4, 2024):

Sorry... My bad. The x-sendfile is in the RESPONSE, not in the request

Not sure I follow. Do you mean it doesn't work?

<!-- gh-comment-id:2147170616 --> @phanan commented on GitHub (Jun 4, 2024): > Sorry... My bad. The x-sendfile is in the RESPONSE, not in the request Not sure I follow. Do you mean it doesn't work?
Author
Owner

@Sp1l commented on GitHub (Jun 4, 2024):

Sorry... My bad. The x-sendfile is in the RESPONSE, not in the request

Not sure I follow. Do you mean it doesn't work?

Correct, it does not work.

<!-- gh-comment-id:2147270807 --> @Sp1l commented on GitHub (Jun 4, 2024): > > Sorry... My bad. The x-sendfile is in the RESPONSE, not in the request > > Not sure I follow. Do you mean it doesn't work? Correct, it does not work.
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#112
No description provided.