October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Secure Roundcube Webmail on Ubuntu (2026 Hardening Guide)

Secure Roundcube on Ubuntu with a narrow public directory, enforced HTTPS, protected PHP logs and temp files, verified IMAP/SMTP TLS, release-aware updates, and a tested Fail2ban jail.
Length13 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Secure Roundcube by maintaining Ubuntu and Roundcube, serving only its public_html directory over HTTPS, keeping PHP diagnostics and temporary files private, preserving TLS certificate verification for mail connections, and using Fail2ban against repeated login failures. The sequence below applies to package-managed and upstream Roundcube installations; package names and corrected versions must be checked against the Ubuntu release running on your server.

What a secure Roundcube deployment looks like

Roundcube is a browser application, so its attack surface includes the web server, PHP runtime, Roundcube code, session cookies, the IMAP and SMTP connections it makes, and the operating system underneath. A secure installation separates those layers instead of relying on a single setting.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Internet edge: Apache or Nginx accepts browser traffic, redirects HTTP to HTTPS, and serves only Roundcube’s intended public directory.
  • Application: Roundcube runs with PHP error display disabled, error logging enabled, and current security updates installed.
  • Mail transport: IMAP, SMTP, and ManageSieve connections validate server certificates and hostnames.
  • Abuse controls: Fail2ban watches Roundcube authentication errors and temporarily bans sources that exceed a conservative threshold.
  • Operations: administrators protect logs and temporary files, remove the installer after setup, monitor bans and errors, and rehearse updates and rollback.

Hardening is not a substitute for secure mail accounts. Use strong, unique passwords, multi-factor authentication where your mail provider supports it, and least-privilege administrative access to the Ubuntu host.

1. Establish the patch baseline before changing configuration

Roundcube security releases

On 6 September 2026, the Roundcube Project announced security updates for both supported lines: Roundcube 1.6.19 (the 1.6 LTS line) and 1.7.4. The project described these releases as fixes for recently reported security vulnerabilities. Treat that date as a minimum baseline, not a reason to pin a version indefinitely: install the newest security update offered for your branch and test it against your plugins and database schema.

#1 Best Overall
BookFactory Security Pass Down Log Book, Wire-O, 100 Pages
  • Made in USA - Proudly produced in Ohio by a Veteran-owned business
  • Comprehensive Coverage: This BookFactory log book includes essential fields such as post/shift, time of change, date, weather conditions, and a designated space for detailed notes. This ensures that all relevant information is captured and easily accessible.
  • Sturdy Cover: The trans-lux cover protects the log book from wear and tear, ensuring its longevity and maintaining the integrity of your recorded data.
  • Essential Security Tool: This log book is an indispensable tool for any organization that values security and accountability. It helps to prevent misunderstandings, improve communication, and ensure a smooth transition between shifts.
  • Wire-O with Trans-lux cover, 100 Pages, Dimensions 8.5" x 11" - (Security-Pass-Down) Reorder SKU: LOG-100-7CW-PP(Security-Pass-Down)

Ubuntu’s backported security model

Canonical describes Ubuntu as a fixed-release distribution that receives backported security patches during each release’s support window. Since Ubuntu 18.04 LTS, unattended-upgrades has been included in default Desktop and Server installations and applies security updates daily by default. Verify that behavior rather than assuming it is enabled on a customized image.

Ubuntu LTS releases receive five years of standard security maintenance for the Main and Restricted components. Longer maintenance windows require Ubuntu Pro under Canonical’s support model. A host running an end-of-life release cannot be made safe merely by enabling unattended upgrades; move it to a supported release or obtain the appropriate extended maintenance coverage.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Identify the release and installed Roundcube build

lsb_release -ds
. /etc/os-release && printf '%sn' "$PRETTY_NAME"
dpkg-query -W -f='${Package} ${Version}n' roundcube-core 2>/dev/null || true
apt-cache policy roundcube-core

Record the output before an upgrade. It gives you a rollback reference and prevents copying a command intended for one Ubuntu release onto another.

Apply Ubuntu updates and verify unattended upgrades

sudo apt update
sudo apt full-upgrade
sudo systemctl status unattended-upgrades --no-pager
sudo unattended-upgrade --dry-run --debug

Schedule maintenance if the upgrade changes PHP, the web server, or Roundcube plugins. Keep a tested backup of the Roundcube configuration, database, and mail server settings. After upgrading, reload the web server and test login, mailbox listing, message reading, sending, and logout from a separate browser session.

Use the release-specific corrected package

USN-8097-1 lists corrected Roundcube packages by Ubuntu release. For Ubuntu 24.04, the advisory lists roundcube-core 1.6.6+dfsg-2ubuntu0.1+esm2; several corrected versions are available through Ubuntu Pro. That value is advisory evidence, not a universal pin. The package manager and the current Ubuntu security notice are authoritative for your release.

apt-cache policy roundcube-core roundcube-plugin-fail2ban
apt list --upgradable 2>/dev/null | grep -i roundcube

If the candidate version is older than the security-fixed build for your release, stop and resolve repository, support-window, or Ubuntu Pro enrollment issues before exposing the site to the Internet.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Choose a package-managed or upstream installation deliberately

Decision factor Ubuntu package Upstream installation
Update cadence Ubuntu integrates updates and backports fixes during the release support window. You track Roundcube releases and apply upstream updates yourself.
Filesystem layout Paths, plugins, and service integration follow Ubuntu packaging conventions. You control the directory layout, but must enforce the public/private boundary yourself.
Rollback APT history and package versions provide a familiar rollback trail, subject to repository availability. You must retain release archives, configuration backups, and a database rollback plan.
Fail2ban integration roundcube-plugin-fail2ban is available from Ubuntu’s Universe repository and depends on roundcube-core. You install and configure the equivalent filter and jail manually, matching your actual log format.

Do not mix files from an APT installation with an upstream tree unless you have documented exactly which code, configuration, and database migrations each component owns. Mixing layouts is a common cause of upgrades silently leaving an old vulnerable copy accessible.

Rank #2
BookFactory Security Incident Report Log Book, Wire-O, 100 Pages
  • Made in USA - Proudly produced in Ohio by a Veteran-owned business
  • This BookFactory log book is for security guards in any sector or business. You can report location, circumstances and report number.
  • There are spaces to log the individual's names address, description and other identifying information. There are also spaces to note others involved, notes, and vehicle information if one was involved
  • Wire-O, 100 Pages, Dimensions 3.5" x 5.25"
  • Reorder SKU: LOG-100-M3CW-PP(Security-Report)

3. Expose only Roundcube’s public directory

Use the documented document root

Roundcube’s installation guide requires the HTTP server document root to point to its public_html directory. This prevents configuration files, logs, temporary data, and the installer from becoming ordinary web paths. Configure a dedicated virtual host for Roundcube rather than placing the application under a broad shared document root.

After identifying the installation directory, confirm that the web server can read the public files but that private directories are not reachable through a browser. A request for a private path should return a denial or a not-found response, never a directory listing or file contents.

Remove or disable the installer

Complete setup from a controlled network, then remove the installer or make it inaccessible. Leaving an installer reachable allows an attacker to re-run configuration steps, discover database details, or overwrite settings. Keep a copy outside the document root if you need it for a future rebuild.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Restrict ownership and permissions

  • Keep application code owned by root or a deployment account rather than by the web-server user.
  • Grant the web-server user write access only to the Roundcube directories that require it, notably logs and temp.
  • Keep configuration files and database credentials unreadable by unrelated users.
  • Disable directory listings and avoid writable directories inside the public tree.

Permission changes must match your web server’s account and the layout created by your package. Check with namei -l and a test request instead of applying a recursive, world-writable permission command.

4. Force HTTPS safely

Obtain and install a trusted certificate

Use an ACME-capable certificate provider appropriate for your deployment and keep its current terms and renewal process under review. The certificate must cover the exact hostname users enter, and the server must send the complete trust chain. Test renewal before the first certificate approaches expiry.

Redirect HTTP to HTTPS

Keep port 80 only long enough to issue a permanent redirect and, where needed, complete certificate validation. The Roundcube virtual host should serve application content on HTTPS; do not rely on users remembering a secure URL.

For Apache, create separate HTTP and HTTPS virtual hosts and redirect the former to the latter. For Nginx, use an HTTP server block that returns a 301 redirect and an HTTPS server block that passes PHP requests to the intended PHP-FPM socket. In either stack, confirm that the proxy passes the original HTTPS scheme correctly if another load balancer is in front.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Enable HSTS only after a complete TLS check

HSTS tells browsers to refuse future HTTP connections. Enable it only after every hostname and required subdomain works over TLS, certificate renewal is reliable, and no service on that host still needs plain HTTP. Start with a short max-age, observe for errors, and increase it gradually. Do not include subdomains or preload behavior until you have verified ownership and TLS coverage for every affected name.

Check cookies and mixed content

Once HTTPS is working, verify that Roundcube session cookies are marked secure by the application or web-server configuration and that the browser loads scripts, styles, and images over HTTPS. A reverse proxy that terminates TLS must pass the correct forwarded-protocol information; otherwise the application may generate insecure links or fail to set secure cookies consistently.

5. Keep PHP errors, logs, and temporary files private

Use production error behavior

Roundcube’s installation guide states that it forces display_errors=Off and log_errors=On. Keep that behavior. Displaying PHP warnings or stack traces to a mailbox user can disclose filesystem paths, SQL details, session information, and plugin internals.

Confirm the effective PHP settings for the FPM pool or Apache SAPI that actually serves Roundcube; changing a command-line PHP configuration does not necessarily change the web runtime. After editing configuration, reload the relevant PHP-FPM service and web server, then generate a controlled test error only in a maintenance window and confirm that the browser receives a generic response while the event is recorded server-side.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Protect errors.log, logs, and temp

Roundcube documents errors.log and requires the logs and temp directories to be writable by the web-server user. They must nevertheless remain protected from direct web access. Keep them outside the public document root where your layout permits; otherwise add explicit deny rules and test them with an unauthenticated request.

  • Set ownership to the service account that writes the files.
  • Use the least permissive mode that still permits logging and temporary-session operation.
  • Rotate logs so an authentication storm cannot fill the filesystem.
  • Restrict log-reader access because error records can contain usernames, host addresses, and diagnostic data.
  • Alert on sudden growth, repeated authentication errors, and permission failures.

Do not place a downloadable backup, SQL dump, plugin archive, or configuration copy below the public directory. Web-server deny rules are a second line of defense, not a reason to store secrets in a web-readable tree.

6. Preserve certificate validation for IMAP, SMTP, and ManageSieve

Roundcube’s documentation says, “PHP validates the ssl certificates by default.” Keep that validation enabled. A self-signed certificate, an incomplete trust chain, or a certificate whose hostname does not match the mail server should produce a connection error that you fix—not a reason to disable verification.

Diagnose the certificate problem

  1. Confirm the hostname configured for the service is the name present in the certificate’s Subject Alternative Name.
  2. Check that the server presents the intermediate certificates required by clients.
  3. Verify the certificate’s validity period and that the Ubuntu host’s clock is correct.
  4. Install the issuing CA in the system trust store when you operate a private CA, following your organization’s trust-management process.
  5. Retest from the Ubuntu host and from a browser after correcting the server certificate.

Scope exceptions to the correct connection

Roundcube identifies imap_conn_options, smtp_conn_options, and managesieve_conn_options for connection-specific settings. Use those options only to express a correctly scoped trust configuration, such as selecting a known CA bundle for a private service. Never set a global “accept any certificate” option to make login work, and do not copy an IMAP exception into SMTP or ManageSieve without validating the separate endpoint.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

After a TLS change, test reading mail, sending mail, and filtering if ManageSieve is enabled. A successful web login alone does not prove that all three back-end connections are authenticated securely.

7. Stop repeated login attacks with Fail2ban

Install the Ubuntu integration

Ubuntu publishes roundcube-plugin-fail2ban in the Universe repository. It depends on roundcube-core and recommends fail2ban, which bans hosts that cause multiple authentication errors.

sudo add-apt-repository universe
sudo apt update
sudo apt install roundcube-plugin-fail2ban fail2ban
sudo systemctl enable --now fail2ban

If the package is already installed, use APT’s candidate version for your Ubuntu release and inspect the files it installs rather than overwriting them with a copied configuration from another distribution.

Configure the Roundcube jail in a local override

Fail2ban’s upstream jail.conf includes a [roundcube-auth] jail with HTTP/HTTPS ports and a Roundcube error-log path. Its dedicated roundcube-auth.conf filter parses Roundcube authentication events. Put local changes in /etc/fail2ban/jail.local or a file under /etc/fail2ban/jail.d/; package upgrades can replace the vendor defaults.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
[roundcube-auth]
enabled  = true
port     = http,https
logpath  = /var/lib/roundcube/logs/errors.log
maxretry = 5
findtime = 10m
bantime  = 1h

The path above is an example. Set logpath to the actual errors.log location on your host, including the path used by an upstream installation. Set maxretry, findtime, and bantime according to your user base and threat level; lower thresholds block attacks faster but increase the chance of locking out users behind a shared address.

Validate the filter before enabling bans

  1. Confirm that the log file exists, is readable by Fail2ban, and contains recent failed-authentication events.
  2. Run the filter’s test command against a copy or controlled sample of the log and verify that only failed Roundcube authentication lines match.
  3. Start with a staging account and a known test source address. Do not test by repeatedly locking a real user’s account.
  4. Inspect the jail status and confirm the expected port, filter, log path, retry count, and ban action.
  5. Keep an administrative console or out-of-band access path available before testing a ban.
sudo fail2ban-client status
sudo fail2ban-client status roundcube-auth
sudo fail2ban-client get roundcube-auth logpath
sudo journalctl -u fail2ban --since '1 hour ago'

Monitor false positives after deployment. Shared corporate NAT, mobile carriers, and forgotten mail clients can generate several valid-looking failures from one address. Unban a verified user only after correcting the cause, and document any trusted network exceptions instead of disabling the entire jail.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

8. Compare the main implementation choices

Apache versus Nginx

Axis Apache Nginx
Best fit Teams already using Apache virtual hosts and its access-control model. Teams already using Nginx and comfortable with a separate PHP-FPM service.
PHP integration May use PHP-FPM through a configured proxy or another supported SAPI. Requires an explicit PHP-FPM upstream/socket configuration.
TLS automation Use the ACME client and virtual-host tooling already standardized in your environment. Use the ACME client and server-block reload process already standardized in your environment.
Logging Access and error logs are straightforward to separate per virtual host. Define separate access and error logs and ensure proxy errors are not mistaken for Roundcube authentication failures.

Neither server is intrinsically safer when the document root, TLS policy, PHP execution, and log permissions are wrong. Familiarity, reproducible configuration, and reliable patching are the deciding factors.

Fail2ban threshold trade-offs

Policy Protection False-positive risk Operational requirement
Short findtime, low maxretry, long bantime Fast response to concentrated attacks. Higher, especially for shared addresses and misconfigured clients. Frequent monitoring and a documented unban process.
Moderate findtime and retry count Good balance for most small deployments. Moderate. Review logs after rollout and after major password changes.
High retry count or short bantime Less disruptive to users but easier for slow attacks to continue. Lower. Compensate with account protections and centralized monitoring.

9. Test the finished deployment

Use a written acceptance checklist so a later package or certificate change does not silently remove a control.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • HTTP requests redirect to HTTPS, and HTTPS presents the correct hostname and complete certificate chain.
  • HSTS is enabled only for names that have been verified over TLS.
  • The web root is Roundcube’s public_html; requests for configuration, logs, temp, and installer paths are denied.
  • PHP errors are not displayed to users, while Roundcube errors are recorded in a protected log.
  • Roundcube login, mailbox listing, message reading, compose, send, and logout all work.
  • IMAP, SMTP, and ManageSieve (if used) reject an invalid hostname or untrusted certificate rather than silently accepting it.
  • Fail2ban’s filter matches a controlled failed login, records the event, and bans according to the selected policy.
  • Log rotation, disk-space alerts, backups, and certificate renewal have been tested.
  • The Ubuntu release, Roundcube branch, package candidate, and last successful update are documented.

10. Troubleshoot common failures

Users see a PHP error or a blank page

Check the protected Roundcube error log and the PHP-FPM or Apache error log. Confirm that the web SAPI loaded the intended PHP configuration, that required PHP extensions are present, and that the web-server user can write to logs and temp. Do not turn on browser error display on a production host.

Fail2ban shows zero matches

Inspect the actual Roundcube errors.log path, permissions, timestamp format, and authentication event text. The filter supplied by the package must match the log format generated by your Roundcube version. Run a controlled failed login, then use fail2ban-client status roundcube-auth and the Fail2ban journal to distinguish a filter problem from a permission problem.

Legitimate users are banned

Look for shared NAT, a stale password in a phone or desktop client, or an overly aggressive retry window. Unban the verified address through Fail2ban, correct the client, and adjust thresholds only after reviewing several events. Avoid broad permanent allowlists that would also exempt an attacker using the same network.

IMAP or SMTP reports a certificate error

Check the service hostname, certificate Subject Alternative Name, intermediate chain, system trust store, and server clock. Correct the mail server or narrowly scoped Roundcube connection setting. Do not disable PHP’s certificate validation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

An update changes the layout or breaks a plugin

Read the package changelog and Roundcube upgrade notes, back up the database and configuration, and test in a staging copy. Confirm that only one Roundcube code tree is reachable from the web server. If rollback is necessary, restore the matching code, database backup, and configuration together; reverting only the visible files can leave an incompatible schema.

11. Maintain the service continuously

Security work ends only when maintenance is routine. Review Ubuntu and Roundcube advisories at each patch cycle, verify that unattended upgrades still run, and check the live APT candidate before applying a production change. The 6 September 2026 Roundcube releases demonstrate why both the application and operating system need independent tracking.

  • Daily: review disk space, certificate-expiry alerts, Fail2ban bans, and unusual authentication volume.
  • At every update: back up configuration and database state, apply the release-specific packages, reload services, and run the functional checklist.
  • Monthly: test restore procedures, review writable paths and virtual-host rules, and remove unused plugins and accounts.
  • Before enabling HSTS changes: test every affected hostname and renewal path.
  • After an incident: preserve logs, rotate credentials, inspect web and mail-server access records, and patch before lifting temporary restrictions.

A secure Roundcube host is therefore a maintained system: current code, a narrow web root, private diagnostics, verified mail TLS, measured brute-force controls, and a tested recovery process.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.