Problems, hosting cockpit in a subfolder on uberspace


i am currently trying to host a site on uberspace in a subfolder. Another cockpit project, that is lying in my root is working perfectly fine, but i somehow struggle to overcome problems with my project in the subfolder. This is the error i am getting:

My project is lying under
but somehow it is trying to resolve the path to
without the html-part.

And this is, how my defines.php is looking like:

define('COCKPIT_DOCS_ROOT', dirname(__DIR__));
define('COCKPIT_BASE_URL', '/cms');
define('COCKPIT_BASE_ROUTE', '/cms');

the root path is btw
and the cockpit project not working is in the / subfolder

sounds like your apache config

Your primary docs root is in /var/www/virtual/$USER/html and all connected domains point to that root if there is no matching folder (secondary docs root) in /var/www/virtual/$USER/sub.domain.tld.

So /var/www/virtual/$USER/ should be the right place.

If you use it that way, $_SERVER['DOCUMENT_ROOT'] still points to /var/www/virtual/$USER/html.


define('COCKPIT_DOCS_ROOT', __DIR__); and eventually RewriteBase / in .htaccess should do the trick.


i moved everything, where it belongs, with the defines.php and RewriteBase / in place and am now getting this:

Without RewriteBase the somewhat same error occurs:

Not found
The requested URL /var/www/virtual/$USER/ was not found on this server

As naive as i am i also renamed the folder to, so that the path actually NEEDS to hit the index.php but unfortunately it does not.

@nino1337 I was able to reproduce your setup with the help of this thread (working example for Uberspace in a secondary docs root, but not in a subfolder):

This works, if your cockpit instance is in a subfolder /cms:

# connect domain
uberspace web domain add test.domain.tld

# set A and AAAA records at your domain provider...

# create docs root
cd /var/www/virtual/$USER
mkdir test.domain.tld
cd test.domain.tld

git clone cms

cd cms

nano .htaccess
# set RewriteBase /cms
# Be aware, that .htaccess might be overridden with the next cockpit update

nano defines.php
# set constants (see below)


define('COCKPIT_BASE_URL', '/cms');
define('COCKPIT_BASE_ROUTE', '/cms');
define('COCKPIT_DOCS_ROOT', dirname(__DIR__));
define('COCKPIT_SITE_DIR',  dirname(dirname(__DIR__)));
1 Like