Skip to main content

🌐 VirtualHost Configuration on Apache (HTTP and HTTPS)

⚠️ All configurations shown in this manual are simple and hypothetical examples. Adaptations may be necessary depending on the topology and structure of your environment.

This guide shows how to configure multiple applications on a single Apache server using VirtualHost files, with support for HTTP and HTTPS on SaveinCloud.


✅ Prerequisites​

Before starting the configuration:

  • The Apache instance must have a public IP or the domains/subdomains need to be linked to the environment and pointed with CNAME to the correct hostname.

  • The applications must be in separate directories inside /var/www/webroot/.

    For example: imagem


🔧 Step 1 – Organize your applications​

Deploy each application in a separate directory, as in the example: imagem


📄 Step 2 – Create the VirtualHost files​

Create a .conf file for each application inside the directory:


/etc/httpd/conf.d/

Example:


touch /etc/httpd/conf.d/app1.seudominio.com.conf

📝 Using the .conf extension is mandatory for Apache to identify and load the file.


🌍 Step 3 – Basic HTTP configuration​

Edit each .conf file with the following structure:


<VirtualHost *:80>

ServerAdmin [email protected]

DocumentRoot /var/www/webroot/app1

ServerName app1.seudominio.com



ErrorLog logs/app1.seudominio.com-error_log

CustomLog logs/app1.seudominio.com-access_log combined

</VirtualHost>

🔁 Change:

  • DocumentRoot to the correct application path.
  • ServerName, ErrorLog, and CustomLog to reflect your domain.

🔐 Step 4 – SSL installation with Let's Encrypt (HTTPS)​

Make sure the domains/subdomains are correctly pointed (type A to public IP or type CNAME to the environment host).

Then, access the Addons tab on the platform:

imagem

With the addons tab open, perform the Let's Encrypt installation:

imagem

During the Addon installation, the SSL screen will appear; there, add the domains you want to configure HTTPS access for:

imagem


📦 Step 5 – HTTPS VirtualHost configuration​

After installing SSL, copy the content of the <VirtualHost *:443> block from the file:


/etc/httpd/conf.d/ssl.conf

Paste the content into the .conf files created in Step 2 and edit according to the example:


<VirtualHost *:443>

DocumentRoot /var/www/webroot/app1

ServerName app1.seudominio.com



ErrorLog /var/log/httpd/app1.seudominio.com.ssl-error.log

CustomLog /var/log/httpd/app1.seudominio.com.ssl-access.log combined



SSLEngine on

Protocols h2 http/1.1

SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1

SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384

SSLHonorCipherOrder off

SSLSessionTickets off

SSLCertificateFile /var/lib/jelastic/SSL/jelastic.crt

SSLCertificateKeyFile /var/lib/jelastic/SSL/jelastic.key

SSLCACertificateFile /var/lib/jelastic/SSL/jelastic-ca.crt



<IfModule headers_module>

Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"

Header always set Expect-CT "max-age=3600, enforce"

</IfModule>

</VirtualHost>


🔁 Step 6 – Restart Apache​

After editing all .conf files, restart the Apache service:

imagem


✅ Verification​

  • Access http://app1.seudominio.com or https://app1.seudominio.com.

  • Make sure the correct content is displayed for each application.


🛠️ Troubleshooting​

❌ Domain not accessible​

  • Check the DNS pointing.

  • Confirm if the .conf file is correct and saved.

❌ HTTPS not working​

  • Verify if the SSL certificate was correctly issued.

  • Confirm if the <VirtualHost *:443> block is present in the .conf.


📘 Additional documentation: