I recently started to test using Koken to self-host some of my photography work and I was having a lot of mysterious issues. My server is configured running nginx and all domains are 100% SSL enabled (using Let’s Encrypt). There is no non-SSL access to any site on my server. Koken is a PHP application built on the CodeIgniter framework, so for php-fpm is in the configuration mix too.
While Koken looks really nice, nice enough for me to spend time trying to resolve my issues, the support is pretty poor. There are hundreds of posts related to these issues, which I have resolved with one configuration item in my nginx configuration. I hope this might solve some problems for a lot of other people since development appears to be very slow. Koken was sold recently and the new maintainers are not releasing updates that often.
The issues apear isolated to people running Koken on nginx with SSL only access. Symptoms of the issue are:
- SSL Mixed Content Warnings
- Unable to Log in, despite using the correct password
- Settings do not save
- Themes will not apply
- Cannot contact API error messages
As it turns out, [crayon-5c13ed7ecddea848138734-i/] is the primary way the application talks to itself, and [crayon-5c13ed7ecddf4543469021-i/] is the primary controller for things. After a bunch of logging and debugging I noticed that [crayon-5c13ed7ecddf6226432600-i/] was making a lot of calls to [crayon-5c13ed7ecddf7515289741-i/] using a non ssl uri. For whatever reason these calls never made it to my 301 redirects (HTTP -> SSL) and would just silently fail – resulting in a bunch of strange issues where the site appears to “mostly work”, but a lot of core functionality seems broken.
Upon realizing that the application was calling the api from http instead of https I was hoping I could resolve the issue without modifying the source code. I did not want to have fiddled with the source such that any time I update it, I would have to remember to patch the files. After a bit of digging I found that Koken determines if a site is running SSL using the following code snippet from [crayon-5c13ed7ecddf8276894792-i/] :
There are a number of places throughout the code which make reference to the [crayon-5c13ed7ecddfc789079969-i/] variable, some deal with it properly, some do not. The above snippet is just one example, to correct the issue in the code itself you would have modify 5 or 6 files. While I feel the Koken developers can fix this on their end, or at least document the configuration change needed to correct it, the fix is quite simple.
In your fastcgi.conf, or the site configuration file, or wherever you store it, add the following line:
This will properly set the [crayon-5c13ed7ecddff719403308-i/] variable to something that will work with how Koken expects to reference it (like Apache), and everything will work fine.
The relevant sections of my entire working koken.conf file for nginx looks like this: