Kirby in Dokku broken with recent update

We have a Kirby installation running in Dokku with the default heroku-buildpack-php. In this setup, Kirby is running in an Apache2 instance at port 5000, which is proxied by the main Nginx server managed by Dokku. This setup has been running perfectly for more than a year.

Every month or so, I update the composer package so it stays up-to-date. Last week I did another update, including one from PHP 7.4 to PHP 8.0. Thatā€™s when things started breaking. For some reason, Kirby is serving all panel assets over HTTP, while the app (in Nginx) is running on HTTPS. I suspect this is because Kirby guesses the protocol from Apache, which is running internally.

For a few days now I have been trying to debug this issue, but I canā€™t make it work. I even deleted the app completely from Dokku and built a new one from scratch. I also tried reverting back to PHP 7.4, but somehow that doesnā€™t work either.

Then I configured 'url' => 'https://sub.domain.com', which fixed the issues to an extent. But then I ran into many other errors copying the original accounts and sessions folders, so Iā€™m running a clean install. Thatā€™s where I am now, with a pushState error from the installation path:

index.js:1 DOMException: Failed to execute 'pushState' on 'History': A history state object with URL 'http://sub.domain.com/panel/installation' cannot be created in a document with origin 'https://sub.domain.com' and URL 'https://sub.domain.com/panel/installation'.

Even though Iā€™m forcing Kirby to use HTTPS, itā€™s still using HTTP there. Isnā€™t there a way to tell Kirby to always use HTTPS, regardless of the environmentā€™s protocol?

UPDATE: If I disable HTTPS, everything works perfectly, so thatā€™s clearly where the issue is. Iā€™ve now managed to do the installation over HTTP, but after installing the cert, itā€™s broken again.

So I found a solution, although it feels a bit hackish. Iā€™m now manually forcing PHP on HTTPS, before initializing Kirby:

<?php

include '../vendor/autoload.php';

$_SERVER['HTTPS'] = getenv('APP_ENV') == 'production';

echo (new Kirby)->render();

If anyone has a better solution, Iā€™m all ears. For now, this seems to work as expected.

2 Likes

Itā€™s great that you found a solution. We are currently also working on an official way to fix this. Sorry for the issue!

2 Likes

@texnixe pointed me to this thread from Mixed content issues with panel - #5 by texnixe as Iā€™ve reverted to 3.5.x and php 7.4 to solve this on my end, I was just curious if there was an issue to track to know when updating to later packages is possible? I wasnā€™t able to find something in the github issue tracker.

1 Like

@bastianallgeier I was just curious if there were any updates to this as PHP 7.4 is reaching EOL in a few months (end of 2022).

I had to deploy this project again after some time and ran into the same issues with the latest versions and ended up having to revert as above.