Krayin: Deploying CRM with Docker and HTTPS Reverse-Proxy Fix: The Production Manual
The Complete Production Guide to Installing & Maintaining Krayin CRM Behind NetBird
How to bypass nested directory bugs, solve missing CSS assets, eliminate mixed-content form errors, and maximize PHP execution speeds.
Krayin is a powerful, open-source Laravel-based CRM. However, configuring its official Docker image behind an HTTPS reverse proxy like NetBird uncovers architectural gaps. Out-of-the-box, the installation script introduces folder ownership deadlocks, broken CSS layouts, and blocked form submissions due to internal HTTP assumptions.
At MSLS Partners, our infrastructure engineers troubleshoot these system-level disconnects daily. This complete manual outlines our exact production adjustments to build a rock-solid, high-performance Krayin stack.
⚙️ Core Architectural Bottlenecks Explained
When deploying Krayin in an enterprise network environment, structural misalignments between the host, the container, and the proxy will degrade security and performance.
👤 Host UID Conflicts
Building images under a root shell forces UID 0 ownership on mounted host volumes, throwing permission errors once non-root runtimes take over.
📁 Nested App Roots
The installation script wraps core application data inside a sub-nested /krayin/ folder, breaking standard container document-root path structures.
🔒 Mixed Content Blocks
NetBird handles edge SSL decryption, but the application engine continues generating plaintext http:// asset links, prompting severe browser validation blocks.
⚡ Bytecode Compilation
Without dedicated memory storage extensions configured, PHP evaluates raw script strings recursively on every single click, introducing extreme I/O disk wait-states.
🛠️ Step-by-Step Installation & Fix Deployment
Step 1: Sanitize Build Context Permissions
Before initializing scripts, ensure your working directories are owned by your standard host user profile rather than root. If volume ownership is locked, clear it globally:
sudo chown -R rhadmin:rhadmin ~/docker/krayin/
Step 2: Hardcode Container Build Target
Open docker-compose.yml. If running commands as an elevated root operator, the default $USER parameter evaluates to "root"—which breaks inside base images since the root system profile already exists. Change it to a generic safe string:
krayin-php-apache:
build:
args:
container_project_path: /var/www/html/
uid: 1000
user: krayin # Changed from $USER to prevent root user collisions
Compile and run the primary initialization architecture:
sh setup.sh
Step 3: Correct Environment Variables & Proxy Domain
Because the installer pulls the CRM source down into a nested structure, target the internal .env file directly to assign localization, turn off debug processes, and map proxy asset URLs:
nano ~/docker/krayin/workspace/krayin/.env
Modify these essential production attributes precisely:
APP_ENV=production
APP_DEBUG=false
APP_URL=https://krayin.YOUR_DOMAIN.com
ASSET_URL=https://krayin.YOUR_DOMAIN.com
APP_TIMEZONE=America/New_York
Step 4: Fix Internal Apache VirtualHost Routing
Because the composer package lives in /var/www/html/krayin/, Apache's default virtual host mapping serves dead index pages. Modify the container configuration directly:
docker exec -it krayin-krayin-php-apache-1 sed -i 's|DocumentRoot /var/www/html/public|DocumentRoot /var/www/html/krayin/public|g' /etc/apache2/sites-available/000-default.conf
docker exec -it krayin-krayin-php-apache-1 service apache2 reload
Step 5: Enforce Global HTTPS Rule (Fixes Form Errors)
To prevent modern browsers from blocking data forms (such as contact creation screens) due to insecure form action schemas, inject an explicit HTTPS enforcement parameter directly into the Laravel framework core initialization class:
nano ~/docker/krayin/workspace/krayin/app/Providers/AppServiceProvider.php
Update the tracking boot() execution block with the code below:
public function boot()
{
\URL::forceScheme('https');
}
⭐ The Production Maintenance Cheat Sheet
Use these commands to manage your production deployment environment. Because files reside in a nested subfolder inside the container, traditional root commands fail unless targeted with exact explicit file paths.
docker exec -it krayin-krayin-php-apache-1 php /var/www/html/krayin/artisan optimize:clear
Flushes and completely removes all internal application configuration dumps, pre-built route caches, mapping definitions, and parsed layout files.
MSLS Admin Tip: Run this command immediately whenever you adjust variables inside your .env file, alter permissions, or apply framework core source edits.
docker exec -it krayin-krayin-php-apache-1 php /var/www/html/krayin/artisan config:cache
Compiles every individual system parameter into a singular localized flat file, optimizing application execution speed by minimizing system files overhead.
MSLS Admin Tip: Always pair this with php /var/www/html/krayin/artisan route:cache on live systems to prevent the engine from re-indexing endpoints on user clicks.
docker exec -it krayin-krayin-php-apache-1 docker-php-ext-enable opcache
Activates PHP's underlying compiled Bytecode memory engine. This prevents raw script files from being compiled during execution by caching engine machine-code straight inside the container RAM.
MSLS Admin Tip: When system load parameters indicate low memory and CPU use but page changes remain slow, enabling OPCache followed by a full container restart (docker restart krayin-krayin-php-apache-1) removes script compilation latency completely.
docker stats --no-stream
Outputs a comprehensive resource consumption snapshot for all running Docker microservices on the system, indicating memory constraints and CPU load metrics.
MSLS Admin Tip: Monitor this when multiple environments co-exist (e.g., Krayin running parallel with Twenty CRM infrastructure blocks) to isolate localized memory starvation limits early.
💼 Need Help with CRM or Docker Deployments?
Setting up containerized environments, secure network proxies, and automated business databases requires precision architecture. If your company needs to deploy stable Docker infrastructure or configure a production-grade CRM system tailored to your team, we have you covered.
Contact MSLS Partners Today
Comments
Post a Comment