LongFlick
LongFlick

Reputation: 1137

Can't get Baikal running in a subdirectory

I try to install Baïkal on a dedicated host with the "regular package". I am using Nginx as webserver but I can't get it running. The official docs are only dedicated to run Baikal on a subdomain (http://baikal.mydomain.com) instead in a subdirectory (http://mydomain.com/baikal). When I open http://mydomain.com/baikal/card.php/addressbooks/IstMe/default/ I only get a "File not found". Any help would be appreciated.

My nginx.conf looks like this one:

location /baikal {
    alias /usr/share/webapps/baikal/html;
    index index.php;
    rewrite ^/.well-known/caldav /cal.php redirect;
    rewrite ^/.well-known/carddav /card.php redirect;

    location ~ ^/baikal/(.+\.php)$ {
        alias /usr/share/webapps/baikal/html/$1;
        fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi.conf;
    }
}

location ~* /baikal/(\.ht|Core|Specific) {
    deny  all;
    return 404;
}

Upvotes: 2

Views: 2713

Answers (4)

walderich
walderich

Reputation: 626

I know that I am very late. But I found this question when searching for installation of Baikal in a subdirectory. Unfortunately I couldn't find any other resource that explains how to do this. But as I finally managed to get it to work, I wanted to share the solution for future reference.

I used the current Baikal documentation as starting point and adapted it like this, using the subdirectory "baikal":

# Route well-known addresses to subdirectory
rewrite ^/.well-known/caldav /baikal/dav.php redirect;
rewrite ^/.well-known/carddav /baikal/dav.php redirect;

# Handle all Baikal-related requests here
location /baikal/ {
    # Baikal HTML root directory, mind the trailing slash
    alias /baikal/installation/baikal/html/;
    index index.php;
    charset utf-8;

    # The HTML base directory does not contain 'Core', 'Specific', etc.
    # directories, so the location block for blocking those is omitted.

    # Handle all PHP files (removed the RegExp captures)
    location ~ \.php {
        try_files $fastcgi_script_name = 404;
        include fastcgi_params;
        # Ensure to remove the subdirectory name from the PHP call
        fastcgi_split_path_info ^/baikal(.+\.php)(.*)$;
        fastcgi_pass php-handler;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

This configuration can be inserted in an existing Nginx server configuration block. After restart of the server, the Baikal administration was working correctly.

But when pointing at the CardDav/CalDav URIs, I received the following error message:

Requested uri (/baikal/dav.php) is out of base uri (/dav.php/)

After searching on the internet and in the administration settings, I scanned the source code, and finally found the configuration settings, responsible for adapting the base URI:

base_uri: 'baikal'

The variable is set to '' by default and must be changed to match the new subdirectory. The setting can be found in the file config/baikal.yaml.

Upvotes: 0

paulgreg
paulgreg

Reputation: 18933

Have you tried to create 2 symlinks from root to html directory like that :

cd /var/www/baikal
sudo ln -s  html/card.php card.php
sudo ln -s  html/cal.php cal.php

Which should gave that result :

ls -lah /var/www/baikal
total 72K
drwxrwxr-x  6 www-data www-data 4,0K nov.  19 12:40 .
drwxr-xr-x 25 www-data www-data 4,0K nov.  19 12:54 ..
lrwxrwxrwx  1 root     root       12 nov.  19 12:40 cal.php -> html/cal.php
lrwxrwxrwx  1 root     root       13 nov.  19 12:40 card.php -> html/card.php

This seems to work for my installation.

Upvotes: 0

Michael
Michael

Reputation: 903

I'd got the same problem. The folowing very simple instance configuration from this article worked great for me:

server {
    listen       [::]:443 ssl;
    server_name  yourdomain.tld;

    root  /usr/share/nginx/baikal/html;
    index index.php;

    ssl_certificate      server.crt;
    ssl_certificate_key  server.key;

    ssl_session_timeout  5m;

    ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers   on;

    rewrite ^/.well-known/caldav /cal.php redirect;
    rewrite ^/.well-known/carddav /card.php redirect;

    charset utf-8;

    location ~ /(\.ht|Core|Specific) {
        deny all;
        return 404;
    }

    location ~ ^(.+\.php)(.*)$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include        fastcgi_params;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

Upvotes: 2

Paolo
Paolo

Reputation: 2254

quite an old post but i've been redirected here searching for a solution to the very same problem ^^
the're's a post about this issue and a possible solution.
here is the configuration for NGINX (this is cut&paste, it is not my work):

location ^~ /baikal { # triggers location of baikal installation, and stop looking for other matches
  index index.php;
  charset utf-8; 

  # curiosity killed the cat 
  location ~ ^/baikal/(?:\.ht|Core|Specific) {
    deny all;
  }

  # this corresponds to the recommended regex for matching php files
  # and piping it to php-fpm
  location ~ ^(.+\.php)(.*) {
    try_files $fastcgi_script_name =404;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    include fastcgi_params;
  }

  # case insensitive matching of static files for maximum caching time
  location ~* \.(?:jpg|gif|ico|png|css|js|svg)$ {
    expires max; add_header Cache-Control public;
  }
}

i use apache so i had no way to test it but this is the starting point i'm using to solve the problem on my web server.

Upvotes: 0

Related Questions