sabre-io / Baikal

Baïkal is a Calendar+Contacts server
https://sabre.io/baikal/
GNU General Public License v3.0
2.5k stars 289 forks source link

Setting the base_uri does not work, results in 404 errors. #1284

Open ioogithub opened 2 months ago

ioogithub commented 2 months ago

Baikal version: 0.95

Expected behaviour: I would like to run baikal behind an apache reverse proxy with a base url baikal. To get this working I need to use the base_uri feature.

I am running the ckulka docker image and was happy to see this parameter in the baikal.yaml file. All other apps I am running support a similar feature and typically it is as simple as setting the parameter. I expect that if I set the base_uri parameter than baikal will make the necessary changes to get it working with the new subdomain uri. Example setting base_uri '/baikal/' will result in a working http://localhost/baikal/. I will be able to see the admin page and login successfully.

Current behaviour: When I set the parameter to 'baikal' or any derivation: /baikal, /baikal/, /baikal. baikal/ none of them work and they all result in 404 page errors.

With base_uri set when I load http://localhost I get a broken page with no images. The links on the page such as Login and Baikal server have been rewritten to http://localhost/baikal however. When clicking on these links such as: http://localhost/baikal/admin I get 404 errors in the logs:

49#49 *1 /var/www/baikal/html/index.php is not found (2: no such file or directory), client: ip, server: , request: "GET /baikal/ HTTP/1.1, host

and

51#51: *3 FastCGI send in stderr: "PHP message: LogicException: Request uri (/dav.php/calendars/users/default) is out of the base uri (baikal/dav.php/) in /var/www/baikal/vendor/sabre/http/lib/Request...

etc.

Steps to reproduce:

  1. start baikal
  2. load initial admin page in browser
  3. stop baikal
  4. edit ./config/baikal.yaml and set the base_uri
  5. start baikal and load the / page, see the images missing
  6. click on the upper left link to the admin page, see various 404 errors in the log.

I tried both the apache and nginx versions same 404 errors on both when using the base_uri.

Alternate solution (also did not work) After many hours of battling with base_uri, I tried a second solution. I am migrating from radicale and the docker image is well documented with instructions for running it behind various reverse proxies and stripping out the trailing base url. I tried adapting it for baikal and unsetting the base_uri however this also resulted in various broken pages and the inability to login.:

RewriteEngine On
    RewriteRule ^/baikal$ /baikal/ [R,L]

    <Location "/baikal/">
        ProxyPass        http://localhost:1234/
        ProxyPassReverse http://localhost:1234/
        RequestHeader    set X-Script-Name /baikal
    </Location>

I also tried using ChatGPT and it just kept suggesting to set the base_uri and double check etc. which leads me to believe it should just work.

I learned about baikal from reddit discussions and several posters commented on spending many hours trying to get the url working so I knew I was going to have a hard time coming into this but I expected I would get it working like all the other selfhosted apps with this similar feature. Please advise on how I can get this working.