SSL and TLS Configuration#
Attention
Allegra does not natively support SSL or HTTPS configuration. To access Allegra securely via HTTPS, you must set up a reverse proxy (such as Nginx or Apache) in front of the Allegra application.
Official Allegra support does not cover SSL configuration, certificate management, or proxy troubleshooting. The following information is provided as a reference example for experienced system administrators.
Using a Reverse Proxy#
It is strongly recommended to run Allegra behind an existing web server
(reverse proxy) such as Nginx or Apache.
The proxy handles HTTPS encryption and forwards requests to the Allegra application
running in Docker or on a local port (for example, 8080).
This setup allows you to:
Use standard HTTPS certificates without modifying Allegra itself
Expose Allegra under a friendly domain name (e.g.
https://allegra.example.com)Keep Allegra running securely on a local port behind your firewall
Note
Allegra itself should never be exposed directly to the Internet. Configure all encryption and access control in your chosen reverse proxy.
Allegra Settings Behind a Reverse Proxy#
Check the following settings in <INSTALLATION_DIRECTORY>/conf/application.properties
(for a Docker installation: the application.properties next to your docker-compose.yml)
and restart Allegra after changing them:
# Send the session cookie over HTTPS only
server.servlet.session.cookie.secure=true
# Proxies that Allegra trusts to pass on the client address
server.tomcat.remoteip.internal-proxies=127.0.0.0/8, ::1/128
server.servlet.session.cookie.secure: the delivered file sets this tofalseso that Allegra also works over plain HTTP. Set it totrueas soon as users access Allegra over HTTPS.server.tomcat.remoteip.internal-proxies: by default, Allegra accepts theX-Forwarded-*headers only from a proxy on the same machine. If your proxy runs on another machine, add its address, for example127.0.0.0/8, ::1/128, 10.0.0.5/32. The Docker package already includes the Docker bridge networks (172.16.0.0/12). Do not add whole LAN ranges: every address listed here can dictate the client IP address that Allegra uses for login lockout and logging.Allegra evaluates the
X-Forwarded-*headers by default (server.forward-headers-strategy=native). No change is required for this.
Note
The proxy examples below assume that Allegra runs under the context path /allegra.
The default context path is / for a native installation (server.servlet.context-path)
and /demo for a Docker installation (CONTEXT in the .env file).
Either set your context path to /allegra or replace /allegra in the examples with your own.
Network Overview#
The following diagram illustrates a typical HTTPS deployment using a reverse proxy:
+---------------------------+
| Web Browser |
| (User accesses Allegra) |
+------------+--------------+
|
| HTTPS (443)
v
+---------------------------+
| Reverse Proxy (Nginx) |
| Handles HTTPS & forwards |
| requests internally |
+------------+--------------+
|
| HTTP (8080, local)
v
+---------------------------+
| Allegra Application |
| (Docker container / JVM) |
+---------------------------+
Nginx Proxy Example#
The following minimal Nginx configuration publishes Allegra securely via HTTPS
and forwards all requests to a locally running instance on port 8080.
server {
listen 80;
server_name allegra.example.com;
return 301 https://$host$request_uri;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 443 ssl http2;
server_name allegra.example.com;
ssl_certificate /etc/ssl/certs/your_cert.pem;
ssl_certificate_key /etc/ssl/private/your_key.pem;
client_max_body_size 100m;
location /allegra/ {
proxy_pass http://127.0.0.1:8080/allegra/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Port 443;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_buffering off;
proxy_redirect http://127.0.0.1:8080/allegra/ https://$host/allegra/;
proxy_cookie_path / /allegra;
proxy_cookie_path /allegra "/allegra; Secure; HttpOnly; SameSite=Strict";
}
}
Note
Replace domain and certificate paths with your own values.
Keep X-Forwarded-Proto and X-Forwarded-Port so Allegra generates correct HTTPS links.
Apache Proxy Example#
For Apache2, first enable the required modules on the command line and restart Apache:
sudo a2enmod proxy proxy_http ssl headers
sudo systemctl restart apache2
Then define a simple forwarding configuration in your virtual host:
<VirtualHost *:443>
ServerName allegra.example.com
SSLEngine on
SSLCertificateFile /etc/ssl/certs/your_cert.pem
SSLCertificateKeyFile /etc/ssl/private/your_key.pem
ProxyRequests Off
ProxyPreserveHost On
# Forward original scheme and port
RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Port "443"
# Forward HTTP and WebSocket traffic
ProxyPass /allegra http://127.0.0.1:8080/allegra upgrade=websocket timeout=120 keepalive=On
ProxyPassReverse /allegra http://127.0.0.1:8080/allegra
# Adjust cookies and set secure flags
ProxyPassReverseCookiePath / /allegra
Header edit Set-Cookie "(?i)^(.*)$" "$1; Secure; HttpOnly; SameSite=Strict"
</VirtualHost>
Note
Replace domain and certificate paths with your own values.
Ensure X-Forwarded-Proto and X-Forwarded-Port are set so Allegra generates correct HTTPS URLs.
The upgrade=websocket parameter forwards WebSocket connections and requires Apache 2.4.47 or newer.
Certificates and Encryption for External Connections#
Allegra also connects to external systems as a client, for example:
Sending email through an SMTP server
Receiving email through an IMAP or POP3 server
Connecting to a directory server (LDAP, optional)
These external connections should always use encrypted protocols (SSL/TLS) to prevent passwords or sensitive data from being transmitted in plain text over the network.
Official and Self-Signed Certificates#
Encrypted communication relies on digital certificates. There are two main types:
Certificates from an official Certificate Authority (CA)
Self-signed certificates
Certificates issued by an official CA are automatically trusted by most browsers and Java runtimes. Self-signed certificates, however, must be manually trusted on client systems.
Installing Self-Signed Certificates#
If you use a self-signed certificate, you must make it trusted by the system or the Java environment that Allegra uses to connect to external services.
To install a certificate for use by Allegra:
Obtain the certificate from your external service (e.g. your mail server). It is usually bound to a hostname such as
mail.example.com.Create a keystore directory in your Allegra home folder:
mkdir <ALLEGRA_HOME>/keystoreImport the certificate into the local Allegra keystore using the
keytoolutility that comes with every Java installation:keytool -keystore <ALLEGRA_HOME>/keystore/<your.domain.com>.ks \ -import -file theServersCertificate.cer
The keystore file must reside in
<ALLEGRA_HOME>/keystore. The file should have the extension.ksand a base name matching the hostname of the remote server.
Importing Certificates into the Java Keystore#
If the above approach does not work or if you prefer to trust the certificate system-wide, you can import it directly into the Java runtime’s default keystore.
On Windows, for example:
cd %JAVA_HOME%\bin
keytool -import -alias <alias> -file theServersCertificate.crt ^
-keystore ..\lib\security\cacerts
You will be prompted for a password.
The default Java keystore password is usually changeit (unless it has been changed).
Note
Importing self-signed certificates requires administrative rights and must be done carefully to avoid compromising system security. Always verify the certificate source before importing.