SugarCRM behaves differently from a brochure CMS when HTTPS is involved. It persists a canonical site_url inside its configuration and database, generates many absolute links for AJAX calls, module loaders, and Sugar's REST v10 API, and it inspects PHP server variables to decide whether the current request is secure. On a managed LiteSpeed stack any mismatch between the stored URL, the scheme the browser requested, and the scheme SugarCRM thinks it is serving turns into redirect loops, blocked assets, or login sessions that silently drop. The work below stays entirely inside an unprivileged hosting account: DirectAdmin for the certificate and file editing, phpMyAdmin for one stored value, and .htaccess plus config_override.php for the application logic.
Issuing the Let's Encrypt certificate and verifying coverage
Before touching SugarCRM, the hostname must have a valid certificate. In DirectAdmin open SSL Certificates for the domain, choose Free & automatic certificate from Let's Encrypt, and tick every hostname SugarCRM will answer on. Most installs run on the bare domain and www, so select both crm.example.com (or your chosen host) and the www variant. If Sugar lives in a subdirectory, the certificate still covers the whole hostname, so no extra entry is needed. DirectAdmin writes the certificate and, when you enable Force SSL with https redirect, it also injects a redirect into the domain configuration. Leave that DirectAdmin-managed redirect off for now: SugarCRM needs its own redirect logic, and stacking two of them is the single most common cause of ERR_TOO_MANY_REDIRECTS.
Confirm issuance succeeded by loading https://crm.example.com directly. A green padlock with no certificate warning means the ACME challenge passed and LiteSpeed is serving the chain. If the browser reports NET::ERR_CERT_COMMON_NAME_INVALID, the hostname you are visiting was not included in the certificate request — reopen SSL Certificates, add the missing name, and reissue. Let's Encrypt certificates on this platform auto-renew through the server's scheduler, so you do not manage renewal cron yourself and you must never attempt to run certbot or edit anything under /etc/.
Correcting site_url and building a clean HTTPS redirect
SugarCRM reads its canonical address from $sugar_config['site_url']. The master value lives in config.php at the SugarCRM document root, but the supported place to change it is config_override.php in the same directory, which Sugar merges on top of config.php and never overwrites during upgrades. Open the File Manager in DirectAdmin, browse to /domains/example.com/public_html (or your Sugar root), and edit config_override.php. Add or update the scheme to HTTPS:
<?php
$sugar_config['site_url'] = 'https://crm.example.com';
$sugar_config['http_only_cookies'] = false;
Match the value exactly to the address users type — include or omit www consistently, and never leave a trailing slash. A mismatch here is what produces the classic symptom where the login page loads over HTTPS but submitting credentials bounces back to the login screen: Sugar validates the request host against site_url and rejects the session when they differ. After saving, clear Sugar's compiled cache by deleting the contents of the cache/ directory (not the directory itself) through File Manager, because the old URL is baked into cached JavaScript group files and Smarty templates.
Now add the redirect at the web-server layer with .htaccess. SugarCRM ships its own .htaccess full of rewrite and security rules; do not replace it. Instead add your HTTPS block immediately after the RewriteEngine On line already present, so it runs before Sugar's internal rewrites:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
The second condition is what keeps LiteSpeed from looping. On this stack TLS can terminate at a front layer and reach PHP with %{HTTPS} unset while the real scheme is carried in the X-Forwarded-Proto header. Without that RewriteCond, every already-secure request still looks insecure to the rule and gets redirected again, generating the loop. Keeping both conditions means a request only redirects when neither signal reports HTTPS.
Teaching SugarCRM's PHP layer that the request is secure
The rewrite rule fixes the browser's address bar, but SugarCRM's PHP code separately checks $_SERVER['HTTPS'] and the port to decide how to build links, set cookies, and respond to REST calls. When TLS is proxied, PHP may see HTTPS empty and SERVER_PORT as 80 even though the visitor is on 443. The result is mixed content: the page frame is HTTPS, but Sugar emits http:// URLs for its JavaScript loaders and API endpoints, which modern browsers block, leaving a blank dashboard or a spinning module list. The browser console shows the tell-tale Mixed Content: requested an insecure resource messages.
Normalize the scheme early so Sugar's own detection reads correctly. Add this to the top of config_override.php, before the config assignments, so it runs on every bootstrap:
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])
&& $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
$_SERVER['HTTPS'] = 'on';
$_SERVER['SERVER_PORT'] = 443;
}
With HTTPS forced on whenever the forwarded header is present, Sugar's link builder and the REST v10 metadata it hands to the Sidecar front end all adopt the secure scheme, and the mixed-content warnings disappear. Pair this with a .user.ini in the Sugar root to harden the session cookie now that every request is HTTPS:
session.cookie_secure = On
session.cookie_httponly = On
session.cookie_samesite = "Lax"
Use SameSite=Lax rather than Strict so that returning from an external OAuth or email link does not strip the session. Changes in .user.ini apply after the PHP worker recycles; in DirectAdmin's PHP Selector you can confirm the active handler is LSAPI, which reads .user.ini per directory without any server restart on your part.
Clearing residual mixed content and validating the result
Some insecure URLs are stored, not generated. Logos uploaded through Admin > System Settings, theme asset paths, and any dashlet referencing an external image can keep an http:// prefix from the pre-SSL period. Rather than hand-editing rows, open Admin > Repair > Quick Repair and Rebuild after changing site_url; this regenerates the cached metadata using the corrected scheme and resolves the majority of internal references. For a company logo that still loads insecurely, re-upload it under System Settings so Sugar rewrites the stored path.
If a stored absolute URL persists in a custom field or layout, you can inspect it safely in phpMyAdmin — opened from DirectAdmin, scoped only to your own database. Run a read-only search such as SELECT id, name FROM config WHERE value LIKE 'http://%'; to locate stray entries before deciding whether a Quick Repair or an AdminCP re-save will correct them. Stay within your assigned database; never issue server-wide statements. If sessions still drop after all of this, delete cache/ contents one more time and clear your browser cookies for the domain, since an old insecure cookie without the Secure flag can conflict with the new secure one. For the deeper data-integrity side of a Sugar-family install, our companion walkthrough on SuiteCRM database maintenance covers repairing tables and indexes through the same toolset. Once the padlock is solid, assets load over HTTPS, and logins hold, you can finally enable DirectAdmin's own Force SSL toggle as a belt-and-braces backstop — but only after confirming the .htaccess rule alone already does the job, so you never run two competing redirects.