getkirby-v2 / panel

This is the deprecated admin panel for Kirby v2.
http://getkirby.com
Other
134 stars 70 forks source link

Multi-site setup breaks panel #287

Closed hellquist closed 9 years ago

hellquist commented 9 years ago

Hi. As I am working on a new Kirby site I was thinking it'd make sense to have it on the same server as my old Kirby (also Kirby 2) site, and share the core files etc (ease of updates via GitHub etc), pretty much exactly as described on http://getkirby.com/docs/advanced/customized-folder-setup

This means I have created a new folder for the new site, which contains "content", "site" and "thumbnails" folders for that particular site, and where I point to those folder via the site.php file I have created (copy/paste + edit) from the URL above, whilst it is still using the other Kirby files from the "old" folder.

I now have that working nicely, and it is really sweet, except for one thing: It has broken the panel for both sites.

Is there any work around for that, or do I have to undo the entire thing now? :)

JimmyRittenborg commented 9 years ago

I'm running a multisite setup (soon in production) and everything works really great - what errors do you get? :)

hellquist commented 9 years ago

Ooh, interesting. So there is hope. :) Basically I get a kirby message saying "this page cannot be found".

If I go to http://mynewsite.dev/panel it redirects me to http://mynewsite.dev/panel/panel/login, which doesn't exist. It does the same on http://myoldsite.dev/panel, i.e. going to http://myoldsite.dev/panel/panel/login.

The two following things could be noted as interesting here too, apart from both sites being in development, so not live yet even though I call one "old" and one "new":

  1. I run on nginx
  2. I have the following folder structure.
    • www
    • Kirby (github repo clone, which domain 1 and domain 2 is pointing to in nginx)
    • assets
    • content
    • kirby
    • panel
    • site
    • thumbs
    • site.php
    • ClientSite (github clone of client specific repo)
    • content (actually not part of the ClientSite github clone, but instead coming from Dropbox)
    • site
    • thumbs

Have I been thinking about this the wrong way? The main reason for the above layout was to avoid nesting the client files with the Kirby clone (i.e to avoid having git projects nested), for easy updating of either, separately. Perhaps that would be possible in another way...?

Oh, yes, I should perhaps add as well that the sites (i.e. the non-panel bits) work perfectly right now, it is just the panel that doesn't want to play ball.

JimmyRittenborg commented 9 years ago

I've setup my sites almost the same way as you, for the same reasons you mention, so yes there is definitely hope for you :smiley:

To me, it seems like an redirection, rewrite issue (nginx) or maybe a routing issue with the way you've configured kirby?

JimmyRittenborg commented 9 years ago

Actually, I can't really see how your multisite setup would affect the panel at all.

Did it work before you made the multisite setup?

hellquist commented 9 years ago

Yeah, it used to work. I'm fiddling with it now, and just as a test I removed the site.php, which basically then serves the non-customized starter theme. When I do that the panel works just fine (though, obviously no longer with the site content I'd like). It is only when I add the site.php that the panel breaks for both sites, and it does that thing that looks like a re-direct.

Also have looked in nginx config file to make sure I haven't got anything weird in there, but it is pretty basic. Are you running nginx too?

JimmyRittenborg commented 9 years ago

Yeah, I'm running nginx too :) It sounds really wierd..

Could you post your site.php for me, here?

hellquist commented 9 years ago

Sure, it looks like this:

<?php

$kirby = kirby();

switch(url::host()) {
  case 'oldSite.dev':
    $kirby->roots->content = $kirby->roots()->index() . DS . 'content' . DS . '';
    $kirby->roots->site    = $kirby->roots()->index() . DS . 'site'    . DS . '';
    $kirby->roots->thumbs  = $kirby->roots()->index() . DS . 'thumbs'  . DS . '';

    $kirby->urls->content  = $kirby->urls()->index() . '/content';
    $kirby->urls->thumbs   = $kirby->urls()->index() . '/thumbs';
    break;
  case 'newSite.dev':
    $kirby->roots->content = $kirby->roots()->index() . DS . '../newSite/content' . DS . '';
    $kirby->roots->site    = $kirby->roots()->index() . DS . '../newSite/site'    . DS . '';
    $kirby->roots->thumbs  = $kirby->roots()->index() . DS . '../newSite/thumbs'  . DS . '';

    $kirby->urls->content  = $kirby->urls()->index() . '../newSite/content';
    $kirby->urls->thumbs   = $kirby->urls()->index() . '../newSite/thumbs';
    break;
}

Would you be able to share your nginx config stuff, especially if you have things in there regarding the panel?

I am starting to think I should perhaps add the newSite as a github submodule to my kirby clone. It wouldn't be as nice/neat/clean but it might teach me a thing or two.

That would make it something like this:

<?php

$kirby = kirby();

switch(url::host()) {
  case 'oldSite.dev':
    $kirby->roots->content = $kirby->roots()->index() . DS . 'content' . DS . '';
    $kirby->roots->site    = $kirby->roots()->index() . DS . 'site'    . DS . '';
    $kirby->roots->thumbs  = $kirby->roots()->index() . DS . 'thumbs'  . DS . '';

    $kirby->urls->content  = $kirby->urls()->index() . '/content';
    $kirby->urls->thumbs   = $kirby->urls()->index() . '/thumbs';
    break;
  case 'newSite.dev':
    $kirby->roots->content = $kirby->roots()->index() . DS . '/newSite/content' . DS . '';
    $kirby->roots->site    = $kirby->roots()->index() . DS . '/newSite/site'    . DS . '';
    $kirby->roots->thumbs  = $kirby->roots()->index() . DS . '/newSite/thumbs'  . DS . '';

    $kirby->urls->content  = $kirby->urls()->index() . '/newSite/content';
    $kirby->urls->thumbs   = $kirby->urls()->index() . '/newSite/thumbs';
    break;
}

I am not too fond of the suggested (on getkirby site) multi-site setup, with one content folder and separate content folders underneath for each domain, as that could become quite messy, and one would have to be quite careful when adding access to eventual developers in-house for the client (you don't want them to have access to all your sites) or the content that is client specific (as you don't want one clients content editor to edit another clients content).

All of the above it just thinking ahead for a situation I am not in right now, so worst case scenario I'll just back down to separate single installs I guess, but it would be nice to solve it too. :)

hellquist commented 9 years ago

Actually made a quick test of putting the newSite in under the "Kirby" folder in my structure (which in reality is the starterkit clone), so it ended up next to "thumbs", "panel", "site" and the other folders, but with its own subfolders as previously described (content, site, thumbs) and amending the site.php accordingly (my second example in previous post).

The front-end of things works fine. Now I get a 403 on the panel (on both domains) though. It could still be nginx config related I guess...hmm...

JimmyRittenborg commented 9 years ago

In my nginx config for panel i have

    location ~ panel/ {
        try_files $uri $uri/ /panel/index.php?$query_string;
    }
JimmyRittenborg commented 9 years ago

My multi-site setup:

/var/www/web /var/www/sites

where web is basicly the starterkit..

in web i have a symlink called sites pointing to my sites dir: /var/www/web/sites => /var/www/sites

so in /var/www/sites i then have my sites like

/var/www/sites/whatever.com /var/www/sites/kirbyisthebest.love /var/www/sites/highfive.xyz

then in my nginx config i then have:

rewrite ^/(assets/.*|thumbs/.*|content/.*)  /sites/$host/$1 last;
rewrite ^/favicon.ico  /sites/$host/assets/images/favicon.ico last;

and my site.php is therefore empty (except for a couple of my own classes i include)..

Maybe that'll work for you too? :smiley:

hellquist commented 9 years ago

Ah, interesting! So that is basically multi-site in a different way than suggested in the Kirby docs!

hellquist commented 9 years ago

Does that give a fresh/clean panel for each of the sub sites though? From looking at that, it (to me) looks like that setup would still share the "site" folder, which then would hold the user accounts/blueprints for the panel, right?

JimmyRittenborg commented 9 years ago

Naa it completely omits the site folder, and your other setup would omit it too (for newSite at least) :)

This way the site folder become a sites folder - nothing is shared between sites except kirby and the panel.

But the way i'm doing it, is more flexible and doesn't need the config in the site.php file

JimmyRittenborg commented 9 years ago

The panel doesn't hold any site specific :)

JimmyRittenborg commented 9 years ago

Is it working for you? :)

hellquist commented 9 years ago

I had to postpone my tests, will try it on another server when I don't have a client project I think. :) I did give it a quick try and didn't get it to work immediately and then went to bed.

So, just to clarify for my soon-in-the-future test, you have nothing in your site.php that is related to the multi-site stuff? And still it works (in that it shares common folders with the separate sites)?

allthosehumans commented 9 years ago

I've got this issue as well. I'm not technically advanced enough to know anything about nginx. I use mamp pro for my local setup. Apparently it has an nginx folder. Not sure if/how it's used though. Let me know if you'd like me to test any possible solutions.

lukasbestle commented 9 years ago

MAMP PRO does not use nginx by default. Actually, the PRO version can't use nginx, but the free one can. Your local dev server uses Apache instead of nginx. :)

hellquist commented 9 years ago

Does that therefore mean that this is an issue on both nginx and Apache? Or am I forgetting another ingredient? My Linux server with nginx and php has nothing to do with mamp or similar. Den 24 nov 2014 20:35 skrev "Lukas Bestle" notifications@github.com:

MAMP PRO does not use nginx by default. Actually, the PRO version can't use nginx, but the free one can. Your local dev server uses Apache instead of nginx. :)

Reply to this email directly or view it on GitHub https://github.com/getkirby/panel/issues/287#issuecomment-64250238.

lukasbestle commented 9 years ago

Does it work on your Linux server? If it doesn't, your configuration might be the problem. I myself have not tested a multi-site setup with the Panel yet, so maybe @JimmyRittenborg can help you.

hellquist commented 9 years ago

Hehe, well, no, as I started this thread, it is not working, as per original description. Jimmy indeed has an interesting work around (outlined above...or below...replying on my phone, so not sure, hehe...) which I have yet to test, but as far as I understand it, if you set up the panel and then you set up multi-site as described in the Kirby docs, it will break (regardless of nginx or Apache, and excluding Jimmy's workaround). Den 24 nov 2014 20:46 skrev "Lukas Bestle" notifications@github.com:

Does it work on your Linux server? If it doesn't, your configuration might be the problem. I myself have not tested a multi-site setup with the Panel yet, so maybe @JimmyRittenborg https://github.com/JimmyRittenborg can help you.

Reply to this email directly or view it on GitHub https://github.com/getkirby/panel/issues/287#issuecomment-64251924.

lukasbestle commented 9 years ago

Oh, sorry. I didn't see that the comment was written by you, not by @allthosehumans. :D

hellquist commented 9 years ago

...and just to clarify, my server is plain vanilla Ubuntu 14.04 server with vanilla nginx install and php5-fpm. No magic/strange customization. Plainest and simplest set-up possible (apart from tightening the security to run web sites), to be able to run on a server with as low spec as possible (which in my case is hosted with Digital Ocean).

Oh...apart from Dropbox which I have installed CLI version of.

allthosehumans commented 9 years ago

@lukasbestle Thanks for the clarification. I guess it's not specifically an nginx issue then. By the way I'm using Kirby 2.0.4. @hellquist Are you using the same? My setup is a basic Kirby starterkit installation with the proper folder permissions to run and a site.php file as per the multisite instructions in the Kirby docs. Nothing more.

hellquist commented 9 years ago

Yes @allthosehumans latest version of everything, and also I had it all working fine in multi-site setup as described in the docs (http://getkirby.com/docs/advanced/customized-folder-setup#multi-site-setup). It was ALL working, and nicely too...except (of course) for the panel (hence this thread). :)

felixdorner commented 9 years ago

+1

Same issue for me... Everything works fine - except the panel when changing folder structure.

I run locally with MAMP and just followed this article: http://getkirby.com/docs/advanced/customized-folder-setup

When opening http://localhost/mysite/panel I got a blank screen. Since I followed the documentation I am wondering why it is not working...

hagatorn commented 9 years ago

I'm having this problem too. Quite odd see no-one has posted on this for some months. Is there a solid fix to this?

can confirm the problem is introduced by adding the following content to the site.php file:

// changing the directory
$kirby->roots->content = $kirby->roots()->index() . DS . 'vendor/mindfulness-content';

// changing the url
$kirby->urls->content = $kirby->urls()->index() . '/vendor/mindfulness-content';

This is pretty much exactly copy and pasted from the docs.

If I leave site.php with only the following it is perfectly happy:

<?php 
$kirby = kirby();

I'm running the following php on apache:

PHP 5.4.16 (cli) (built: Oct 31 2014 12:59:36) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
hagatorn commented 9 years ago

I've made a new and I think totally related issue https://github.com/getkirby/panel/issues/409 Maybe unnecessary but I thought it was useful for clarity and as this thread is some months old.

hellquist commented 9 years ago

"I'm having this problem too. Quite odd see no-one has posted on this for some months. Is there a solid fix to this?"

No fix as far as I know. I had to work around it all in my set-up. I shall follow your other thread as well, as this is still very much a scenario I would love if it worked.

hagatorn commented 9 years ago

Your work around is an ngnx config rule? I had a quick go at trying to do something similar in .htaccess but I'm not really that good with .htaccess. Could probably solve it with a post on stack overflow and some experimentation. Would be good to get that set up while we wait for a fix. I believe that kirby may be more modular on a subsequent release so even the cms bit can easily be loaded from a package manager.

hagatorn commented 9 years ago

This is the rule I guess. You just delete the site.php file? rewrite ^/(assets/.|thumbs/.|content/.*) /sites/$host/$1 last;

hellquist commented 9 years ago

Hehe, the only one with a working work-around is @JimmyRittenborg and yes, he is using rewrite rules as outlined by his post (above). My "work around" was to not do it at all for now, and use separate "installs", which doesn't solve the problem discussed in here at all, but rather avoids it alltogether, with the cost of more annoying management/updates etc.

My ideal would still be to have one install of kirby, one install of panel and still being able to use it all for multiple sites, whilst still having clear/clean update paths and separated assets/content. That I have yet to solve.

hagatorn commented 9 years ago

used symbolic links ln -s vendor/mindfulness-content/ content

bastianallgeier commented 9 years ago

I'm super late to the party! Sorry for that!!

The panel makes some issues when the base URL is not set correctly. So please try setting the index url:

$kirby->urls->index = 'http://example.com';