owncloud / music

:notes: Music app for ownCloud
GNU Affero General Public License v3.0
553 stars 198 forks source link

Ampache api with nextcloud served by nginx gets 404 when following nextclou admin docs #851

Open aleixq opened 3 years ago

aleixq commented 3 years ago

Setting nginx site as it's explained in nextcloud administration docs for nginx: https://docs.nextcloud.com/server/21/admin_manual/installation/nginx.html , the php location block breaks ampache api as it splits the path from last ".php" found (xml.server.php) using fastcgi_split_path_info ^(.+?\.php)(/.*)$ . Using https://example.org/index.php/apps/music/ampache/server/xml.server.php works...

paulijar commented 3 years ago

Thanks for the info. Do you have some suggestion, what should be changed in the Music app? Or is the point that the Nextcloud admin docs should not be followed?

aleixq commented 3 years ago

Paul, as ampache api endpoint of music app follows the specification of ampache docs, I think the only way is to add a new location block or tweaking the php handler block in nginx conf. I am gonna test later which one helps there.

aleixq commented 3 years ago

What is working for me is replacing try_files directive of php handler specified in https://docs.nextcloud.com/server/21/admin_manual/installation/nginx.html#nextcloud-in-the-webroot-of-nginx :

--- nextcloud-old.conf  2021-05-05 01:02:35.871870022 +0200
+++ nextcloud.conf      2021-05-05 01:03:11.491904219 +0200
@@ -113,7 +113,7 @@
         fastcgi_split_path_info ^(.+?\.php)(/.*)$;
         set $path_info $fastcgi_path_info;

-        try_files $fastcgi_script_name =404;
+        try_files $fastcgi_script_name /index.php$fastcgi_script_name?$args;

         include fastcgi_params;
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

But as it touches the main php handler of the whole nextcloud maybe there are some problems somewhere ...

pled commented 5 days ago

HI, Same issue here using Docker Nextcloud 29 + Swag containers (Swag is nginx+fail2ban+letencrypt, from linuxserver.io). I get the same error when trying to connect Power Ampache 2 Android app. to Nextcloud Music App.

I can see this issue open for 3 years, does that mean it will not be fixed ?

paulijar commented 5 days ago

@pled I don't believe that there's anything that the Music app could do to help the situation if the problem is in the nginx configuration. Frankly, configuring web servers has always seemed to me to be like some kind of black magic and I have a bit hard time following, what's the root cause of this issue.

lachlan-00 commented 4 days ago

nextcloud is stripping the .php from the url?

You could probably just set a new location in the config for the server

    location /apps/music/ampache/server/ {
    }

and then remove the fastcgi_split_path_info or copy the default settings without it into the folder

(DISCLAIMER that i have no idea how to use nginx)

pled commented 4 days ago

@paulijar : yes, I agree this is related to nginx configuration and not Music App.

And looking at that nextcloud documentation page, it is mentionned that only Apache is officially supported. Nginx configuration examples are community-maintained...

Nevertheless, applying the try_files directive suggested by @aleixq makes Power Ampache able to connect to Nextcloud Music app. So may be the above documentation could be amended with that issue in the Tip and tricks section ? Not sure who and how to contact someone about this... I am sure nginx is widely used, specially with docker Nextcloud implementations.

paulijar commented 4 days ago

I suspect that https://github.com/nextcloud/documentation/issues would be the correct place to request changes/additions to the Nextcloud documentation.