Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could you implement infcloud with your docker image #13

Closed
BobWs opened this issue Mar 11, 2019 · 17 comments
Closed

Could you implement infcloud with your docker image #13

BobWs opened this issue Mar 11, 2019 · 17 comments

Comments

@BobWs
Copy link

BobWs commented Mar 11, 2019

Could you implement https://www.inf-it.com/open-source/clients/infcloud/ with your baikal image.
I've found this image: https://hub.docker.com/r/plaguedr/baikal/ but it isn't working for me. The calendar kept giving me an error.

It would be nice If you could do this with your image as it is a very stable container.

@ckulka
Copy link
Owner

ckulka commented Mar 19, 2019

I'll look into it... although I'd currently go for a separate "infocloud" image and add examples on how to make them work together. Can you let me know what set up you're planning, i.e. the cross-domain or same-origin scenario?

@BobWs
Copy link
Author

BobWs commented Mar 22, 2019

I'll look into it... although I'd currently go for a separate "infocloud" image and add examples on how to make them work together. Can you let me know what set up you're planning, i.e. the cross-domain or same-origin scenario?

A separate “infcloud” sounds good to me. If you could add examples how to make them work together would be great! I guess my setup would prefer same-origin scenario.
Thanks!

@alfureu
Copy link

alfureu commented Apr 3, 2019

+1 I am planning to implement/begging for a baikal+infcloud setup, cross-domain (but on the same hardware), as with a 2-separate docker images unfortunately infcloud sees baikal as cross-domain (and hardest to set up).

@ckulka
Copy link
Owner

ckulka commented Aug 25, 2019

Hi all,

sorry this took so long - there are good and bad news.

The good news is that an image with InfCloud 0.13.1 exists, including an example with Baikal.

The bad news is though that I couldn't get it to work with Baikal yet, because Digest Authentication doesn't seem to work. I'm not sure if it's because the configuration in the config.js is incorrect or if it's the JS/browser incompatibility mentioned in InfCloud's readme.

So far I've only added CORS headers to the nginx configuration file to keep this repository as clean and simple as possible. Once I know - and all help and PRs are welcome here - how the correct setup looks like, I'll check which repositories and images get the code update.

Like before, due to the number of images being built on Docker Hub, it might take a few hours until the new images are available.

ckulka added a commit to ckulka/infcloud-docker that referenced this issue Aug 25, 2019
@BobWs
Copy link
Author

BobWs commented Aug 31, 2019

Have you already taken a look at this repo https://github.com/bjuretko/docker-baikal-infcloud
I have tested it but didn’t like the way how the setup works and it wasn’t conform my present setup. But maybe you can use something for your images

@BobWs
Copy link
Author

BobWs commented Aug 31, 2019

Did you try to set DIGEST to BASIC? As described here https://thomastaucher.at/pages/infcloud-in-conjunction-with-baikal/

ckulka added a commit to ckulka/infcloud-docker that referenced this issue Aug 31, 2019
@ckulka
Copy link
Owner

ckulka commented Aug 31, 2019

Thanks for the hint - this might have solved it, my local tests here worked, but I don't have a full setup where I could do further testing.

Can you give it a try? I've added an example Docker Compose file and config.js file to the repository which worked in my test runs.

@BobWs
Copy link
Author

BobWs commented Sep 1, 2019

Thanks for the hint - this might have solved it, my local tests here worked, but I don't have a full setup where I could do further testing.

Can you give it a try? I've added an example Docker Compose file and config.js file to the repository which worked in my test runs.

Sure I can give it a try, but I have a few questions first before messing up my setup. At the moment I have the following setup: baikal 0.4.6 on Apache with mariadb 10.* will this work with infcloud nginx? And also do I need to install the php docker image as well as you described in your comment?

@BobWs
Copy link
Author

BobWs commented Sep 12, 2019

I can seems to get this to work. I've followed your examples but I keep getting an error page when surfing to the infcloud-page http://my-host-ip:portnummer I'm getting 403 Forbidden.

Could you please clarify things please!

@konfiot
Copy link

konfiot commented Dec 28, 2020

There's still a problem because NGINX is returning a 401 when the preflight OPTIONS request is sent by the browser without authentication, and therefore the browser doesn't even send a PROPFIND because the preflight failed
That seems to be a side effect of the solve of #19

@BobWs
Copy link
Author

BobWs commented Dec 29, 2020

I still haven’t managed to get this to work with my Baikal (latest) version. This guy managed to make it work but his repo is outdated. https://github.com/bjuretko/docker-baikal-infcloud

@konfiot
Copy link

konfiot commented Dec 29, 2020

Yes but both baikal and infcloud are on the same domain so he doesn't have the cross-domain problem

@ckulka
Copy link
Owner

ckulka commented Jan 5, 2021

Sorry, feeling bad for neglecting this - I'll have another run at this after I come back from vacation. I might have some progress on the weekend of Jan 16th.

@BobWs
Copy link
Author

BobWs commented Jan 6, 2021

Sorry, feeling bad for neglecting this - I'll have another run at this after I come back from vacation. I might have some progress on the weekend of Jan 16th.

No worries m8, don’t feel bad! You got to what you got to do and only if you have enough spare time for this then you can work on it. We do understand that developers also have a life beside programming 😉.
When you have time we shall see what you have for us.

Thanks for all your hard work and keeping the Baikal image up to date.

@ckulka
Copy link
Owner

ckulka commented Jan 20, 2021

Ok, I think I now know why all this happens:

  • DAV clients use OPTIONS requests as part of the protocol and expect an answer from Baikal
  • Browsers use OPTIONS requests for CORS and expect a typical CORS response

Only returning the typical CORS response doesn't work, it results in #19. Only returning Baikal responses doesn't work, it results in the issue we have here.

I tried to come up with an Nginx configuration that:

  • only adds CORS headers if requests are sent by a browser
  • doesn't forward preflight requests from browser to Baikal
  • only forwards requests to Baikal that aren't preflight requests

I need someone to test it though... could you please try the following configuration file. Happy to do a call with someone and do live debugging to sort this out, just let me know.

# /etc/nginx/conf.d/default.conf
# Based on http://sabre.io/baikal/install/

server {
  listen 80;
  server_name _;

  root   /var/www/baikal/html;
  index index.php;

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

  charset utf-8;

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

  # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  location ~ ^(.+\.php)(.*)$ {
    try_files $fastcgi_script_name =404;
    include        /etc/nginx/fastcgi_params;
    fastcgi_split_path_info  ^(.+\.php)(.*)$;
    fastcgi_pass   unix:/var/run/php/php7.4-fpm.sock;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param  PATH_INFO        $fastcgi_path_info;

    # Add CORS support, e.g. for InfCloud
    # See
    # - https://enable-cors.org/server_nginx.html
    # - https://www.inf-it.com/infcloud/readme.txt section 3
    # - https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/

    # cors_flags is 0 : Not a browser request, not a preflight request
    # cors_flags is 1 : Browser request, not a preflight request
    # cors_flags is 11: Preflight request sent by a browser
    set $cors_flags 0;
    if ($http_user_agent ~ "Mozilla") {
      set $cors_flags 1;
    }
    if ($request_method = 'OPTIONS') {
      set $cors_flags "${cors_flags}1";
    }

    # Browser preflight request: add CORS headers and don't forward to Baikal
    if ($cors_flags = 11) {
      add_header 'Access-Control-Allow-Origin' '*' always;
      add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PROPFIND, PROPPATCH, REPORT, PUT, MOVE, DELETE, LOCK, UNLOCK' always;
      add_header 'Access-Control-Allow-Headers' 'User-Agent,Authorization,Content-type,Depth,If-match,If-None-Match,Lock-Token,Timeout,Destination,Overwrite,Prefer,X-client,X-Requested-With' always;

      # Tell client that this pre-flight info is valid for 20 days
      add_header 'Access-Control-Max-Age' 1728000;
      add_header 'Content-Type' 'text/plain; charset=utf-8';
      add_header 'Content-Length' 0;

      return 204;
    }

    # From browser, but not a preflight request: add CORS headers and forward to Baikal
    if ($cors_flags = 1) {
      add_header 'Access-Control-Allow-Origin' '*' always;
      add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PROPFIND, PROPPATCH, REPORT, PUT, MOVE, DELETE, LOCK, UNLOCK' always;
      add_header 'Access-Control-Allow-Headers' 'User-Agent,Authorization,Content-type,Depth,If-match,If-None-Match,Lock-Token,Timeout,Destination,Overwrite,Prefer,X-client,X-Requested-With' always;
      add_header 'Access-Control-Expose-Headers' 'Etag,Preference-Applied' always;
    }
  }
}

@theniwo
Copy link

theniwo commented Jan 23, 2021

That works for me. No issues so far. Thank you.

ckulka added a commit that referenced this issue Jan 24, 2021
CORS isn't needed or required for Baikal, but only for other applications like InfCloud. Hence moving CORS configuration to ckulka/infcloud-docker as part of #13 , #19 and ckulka/infcloud-docker#1.
@ckulka
Copy link
Owner

ckulka commented Jan 24, 2021

Thanks for testing @theniwo ! I moved the CORS configuration from this repository over to ckulka/infcloud-docker.

Reason for removing it from here is because Baikal doesn't require or need CORS by itself and I want to remove complexity as much as possible to avoid issues like #19.

The example on how to use Baikal + InfCloud can be found here at ckulka/infcloud-docker: examples/docker-compose.baikal.yaml.

Closing this issue since it looks like we're good, but please let me know if this doesn't work for one of you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants