sagemathinc / cocalc

CoCalc: Collaborative Calculation in the Cloud
https://CoCalc.com
Other
1.17k stars 216 forks source link

Sharing symlinks broken and issues with raw HTML #6547

Open mforbes opened 1 year ago

mforbes commented 1 year ago

I am trying to share a static website as per the instructions here, and I am running into a few issues.

  1. I originally tried to share a folder via following a symlink. This breaks with an error:

    Error loading file
    There was a problem loading this file in [Computers/Website/_build/output.](https://cocalc.com/share/public_paths/c3f1b95a30d46f521b02d9ee0e8bc0f5f1b2ba39)
    
    Error: ENOENT: no such file or directory, lstat '/storage/shares/default/project-13fd6946-fdd9-474e-a824-5ba2b0d7efda/Computers/Website/_build/output'

    Presumably the sharing link is being done through the symlink, but the server can't follow the symlink for some reason.

  2. Sharing the actual folder kind of works in that the HTML files can be embeded, but they can't be served up raw.
    • Opening the folder as raw gives an Internal Server Error.
    • Open the index.html triggers a download (at least on Chrome).

The best I can do is to embed it , but this leads to multiple nesting when navigating.

(I am trying to use Nikola to generate a draft version of our site for students to edit, and wanted to host a backup here for a bit because our main server is down due to electrical work.)

williamstein commented 1 year ago

For simple html you may have better luck with github pages. It's kind of complicated and daunting at first, but there's a lot of docs and it does work. Basically you put your page in a github repo, configure some things, and github serves it. CoCalc's share server is much better for doing things like rendering jupyter notebooks and other content that isn't just plain static html.

Regarding the symlink, that's not going to work at all, because cocalc copies the files out of your project to a completely different server, and serves them from there.

I think our docs used to be right but are not correct now. The problem is that you could put all kinds of nasty XSS attacks, etc., in a static html site, and people via https://cocalc.com/share/... are going to be subject to those attacks. So the html that gets served must be highly sanitized, or only allowed to be downloaded. I do host a couple of sites (e.g., https://wstein.org), but they have a different domain name, so the various attacks aren't a problem. Github similar does something with different domain names for any github pages. The only way to do what you want here is if we had subdomains, e.g., https://forbes.cocalc.com. Someday we may do that... or maybe we'll just outsource such hosting to cloudflare pages or github pages...

mforbes commented 1 year ago

That should be pretty easy since Nikola provides a github pages deployment target (I have used it in the past). I just thought this might work (one stop shopping:-). While people are working on the pages, we can always run an in-project server which works fine for editing.

Thanks.

mforbes commented 1 year ago

@williamstein Perhaps I closed this prematurely: do you want me to leave it open but change it to a request to update the docs?

williamstein commented 1 year ago

Yep, the docs are now wrong.