Installation: Too many redirects

Hi all,

I am just trying to setup Cockpit on a subdomain (shared host on Strato). The subdomain currently support no https, but I hope that´s not an issue.

What I´ve done so far:

  • Copied Cockpit into /cms on the document root
  • Point the subdomain to /cms
  • Created defines.php with this content:
<?php

define(‘COCKPIT_BASE_URL’, ‘/’);

define(‘COCKPIT_BASE_ROUTE’, ‘/’);
define(‘COCKPIT_DOCS_ROOT’, dirname(DIR));

First time start seems to work. I could login in as admin/admin.

But when I open cms.myurl.com it redirects multiple times to cms.myurl.com/auth/login and reports error ERR_TOO_MANY_REDIRECTS.

I added a debug script to bootstrap.php to display some constants:

[COCKPIT_ADMIN] => 1<
[COCKPIT_START_TIME] => 1584809491.7669
[COCKPIT_CLI] =>
[COCKPIT_BASE_URL] => /
[COCKPIT_BASE_ROUTE] => /
[COCKPIT_DOCS_ROOT] => /mnt/web223/b3/49/xxxxxxxx/htdocs
[COCKPIT_DIR] => /mnt/web223/b3/49/xxxxxxxx/htdocs/cms
[COCKPIT_ENV_ROOT] => /mnt/web223/b3/49/xxxxxxxx/htdocs/cms
[COCKPIT_API_REQUEST] => 0
[COCKPIT_SITE_DIR] => /mnt/web223/b3/49/xxxxxxxx/htdocs
[COCKPIT_CONFIG_DIR] => /mnt/web223/b3/49/xxxxxxxx/htdocs/cms/config
[COCKPIT_STORAGE_FOLDER] => /mnt/web223/b3/49/xxxxxxxx/htdocs/cms/storage
[COCKPIT_ADMIN_CP] => 1
[COCKPIT_PUBLIC_STORAGE_FOLDER] => /mnt/web223/b3/49/xxxxxxxx/htdocs/cms/storage
[COCKPIT_CONFIG_PATH] => /mnt/web223/b3/49/xxxxxxxx/htdocs/cms/config/config.yaml

Currently I am stuck. Can anyone help, please?
Thanks.

I’m not 100% sure, but I think COCKPIT_SITE_DIR should point to /htdocs/cms, too. I only had one Cockpit project on a strato host and I used cockpit in a subdirecotry without a sub domain. So example.com/cockpit worked with just defining

<?php
// strato environment, root is in subdir, but domain points to root/subdir
// cockpit is in root/subdir/cockpit
if (!defined('COCKPIT_BASE_URL'))   define('COCKPIT_BASE_URL', '/' . basename(__DIR__));
if (!defined('COCKPIT_BASE_ROUTE')) define('COCKPIT_BASE_ROUTE', COCKPIT_BASE_URL);
if (!defined('COCKPIT_DOCS_ROOT'))  define('COCKPIT_DOCS_ROOT', dirname(__DIR__));

Maybe you have to set RewriteBase / in .htaccess, too.

See also this thread

Oh, and if you are forced to use strato, don’t forget to add a .htaccess file in your public root directory that denies all or redirects to your main domain. Otherwise customer_id.swh.strato-hosting.eu exposes all files above /htdocs - and you made your customer id public in your screenshot.

Cockpit should work fine without https, but in general it is a big issue :wink:

Thanks for the reply and for pointing out the posted id. I edited my post.

Now I pointed COCKPIT_SITE_DIR to /htdocs/cms but it results in the same problem.
I also commented the “RewriteBase” back in in the shipped .htaccess file without success.

Oh, and if you are forced to use strato, don’t forget to add a .htaccess file in your public root directory that denies all or redirects to your main domain

So I need to add the .htacces file to the web page folder, right? For example:
/mnt/web223/b3/49/xxxxxxxx/htdocs/webpage/.htaccess

Maybe I will place cockpit in a subfolder of the webpage if I don´t find a solution. That domain contain a valid SSL certificate as well.

I’m sorry, that it didn’t work. I was able to run it for my use case once and if I ever have to touch strato again, I’ll grab my notes from the last project and try to fiddle with it.

Maybe RewriteBase /cms works…

Or maybe @serjoscha87 has a hint? He mentioned, that his agency has a huge internal strato issue wiki.

No! Strato is ugly, bad, slow and insecure: /mnt/web223/b3/49/xxxxxxxx/htdocs/.htaccess. It looks, like you could store secret files in this directory, because their user interface forces you to point all your domains to sub directories, but their id url exposes that parent directory. Before I posted my last answer, I did a quick test and I was able to access your test setup at customer_id.swh.strato-hosting.eu/cms and id redirected me to customer_id.swh.strato-hosting.eu/auth/login.

Sorry for the flaming, but everytime I worked with this hoster, I had a ton of problems and the easiest solution was to create a dns entry to a different hoster.

did not read all the stuff in this post yet, just saw there is a strato problem (strato s**** in so many aspects - I often had hard times messing around with this s**** provider… :angry: :angry: :angry: )

try putting

// STRATO FIX
$_SERVER['DOCUMENT_ROOT'] = rtrim($_SERVER['PHPRC'], DIRECTORY_SEPARATOR);
// ------------

to the very top of the index.php (located in the document root)

somehow strato sets up the server env vars another way just every other provider does, leading us to some strange problems. This line above should make cockpit being able to deal with the strato env condition.

*edit: I absolute agree with raffaelj and the things he is saying about strato… This provider made me go completely mad… not just once