kd2org / karadav

Lightweight NextCloud compatible WebDAV server
https://fossil.kd2.org/karadav/
GNU Affero General Public License v3.0
155 stars 14 forks source link

Can't find index.php, but don't look at the right place #15

Closed trev0r-STA closed 2 years ago

trev0r-STA commented 2 years ago

Hello I'm trying to test karadav, but there is a little problem. my setup Debian 11, PHP 8.1, Nginx 1.18.0, Karadav 0.3.3 Karadav root's folder: /usr/local/share/karadav Data folder: /home/data and I've put a symbolic link to /home/data in the karadav root folder When I try to go to Manage my files with the demo user (or with a user that I've create, I get an error 404, and in the log I've the following line: 2022/11/14 21:43:10 [error] 3700999#3700999: *264 "/usr/local/share/karadav/www/files/user/index.php" is not found (2: No such file or directory), client: XX.XX.XX.XX, server: karadav.example.com, request: "GET /files/user/ HTTP/2.0", host: "karadav.example.com", referrer: "https://karadav.example.com/" (I've replace the user name by user, and the real hostname by karadav.example.com :-))

If you need more information to investigate, feel free to ask. Thanks

trev0r-STA commented 2 years ago

All right I've made some progress, it was the rewriting rules which are not correct. Now, the webUI is working, but I can't connect a client: Nextcloud, OwnCloud, desktop or mobile app (version tested on the home page of the project), no one will work. When I try to connect, every app say: "404 Not Found" at "GET https://karadav.example.com/status.php" There is no status.php anywhere... What's wrong with my configuration ?

` server { server_name karadav.example.com;

root /usr/local/share/karadav/www; index index.php;

access_log /var/log/nginx/karadav.access.log; error_log /var/log/nginx/karadav.error.log;

charset utf-8;

location / { try_files $uri $uri/ @rewrite; }

location @rewrite { if (!-e $request_filename){ rewrite ^(.*)$ /_router.php; }

location ~ ^(.+.php)(.)$ { try_files $fastcgi_script_name =404; include /etc/nginx/fastcgi_params; fastcgi_split_path_info ^(.+.php)(.)$; fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; }

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/karadav.example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/karadav.example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server { if ($host = karadav.example.com) { return 301 https://$host$request_uri; } # managed by Certbot

listen 80; server_name karadav.example.com; return 404; # managed by Certbot
} ` Thanks for your help

bohwaz commented 2 years ago

Your config redirects everything ending with .php to FPM. So when you request status.php, FPM is called, it looks for a file named status.php, can't find it, and returns a 404.

You need to set up your config so that non-existing .php URLs are sent to _router.php, like this:

    location ~ \.php {
        try_files $uri $uri/ /_router.php?$query_string;
...

This should be good like that.

trev0r-STA commented 2 years ago

I understand what you mean. But as I'me not an expert with Nginx, where should I put this line of code in my config file. I've tried to placed it just before the fpm part, but with no success :-(

bohwaz commented 2 years ago

Replace your try_files line in the php block by the one I provided.

bohwaz commented 2 years ago

I am closing this issue as it is a server configuration issue on your side.

trev0r-STA commented 2 years ago

:+1: