oneonelamp

Create a virtual host for a custom application

Understand virtual host configuration files

Recent versions of Bitnami apps ship three configuration files in the /opt/bitnami/apps/myapp/conf/ directory: httpd-app.conf, httpd-prefix.conf and httpd-vhosts.conf.

  • The httpd-app.conf file is the main configuration file for the application. It could have different content depending on the application:

    <Directory "/opt/bitnami/apps/myapp/htdocs">
        Options +MultiViews
        AllowOverride None
        <IfVersion < 2.3 >
        Order allow,deny
        Allow from all
        </IfVersion>
        <IfVersion >= 2.3>
        Require all granted
        </IfVersion>
    </Directory>
    
    Include /opt/bitnami/apps/myapp/conf/htaccess.conf
    

    For security and performance reasons, it is advisable to not set AllowOverride All to anything other than None (refer to this Apache note for more information). Bitnami applications store this configuration in the /opt/bitnami/apps/myapp/conf/htaccess.conf file (more information).

  • The httpd-prefix.conf file ships the default configuration for the applications in “prefix” mode, such that the application can be accessed at (for example) http://example.com/myapp.

    Alias /myapp/ "/opt/bitnami/apps/myapp/htdocs/"
    Alias /myapp "/opt/bitnami/apps/myapp/htdocs"
    
    Include "/opt/bitnami/apps/myapp/conf/httpd-app.conf"
    
  • The httpd-vhosts.conf file contains the default configuration for virtual hosts, for applications to be accessed at (for example) http://myapp.example.com.

    <VirtualHost *:8080>
      ServerName myapp.example.com
      DocumentRoot "/opt/bitnami/apps/myapp/htdocs"
      Include "/opt/bitnami/apps/myapp/conf/httpd-app.conf"
    </VirtualHost>
    
    <VirtualHost *:8444>
      ServerName myapp.example.com
      DocumentRoot "/opt/bitnami/apps/myapp/htdocs"
      SSLEngine on
      SSLCertificateFile "/opt/bitnami/apps/myapp/conf/certs/server.crt"
      SSLCertificateKeyFile "/opt/bitnami/apps/myapp/conf/certs/server.key"
      Include "/opt/bitnami/apps/myapp/conf/httpd-app.conf"
    </VirtualHost>
    

Define virtual host configuration

To configure your application to use a virtual host instead of the prefix URL, make these changes:

  • Delete the following line in the /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf file:

    Include "/opt/bitnami/apps/myapp/conf/httpd-prefix.conf"
    
  • Add a new link in the /opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf file:

    Include "/opt/bitnami/apps/myapp/conf/httpd-vhosts.conf"
    
    • Some applications require further changes in configuration files or the database. Please check the exact changes in the application’s documentation.

NOTE: After modifying the Apache configuration files, restart Apache to apply the changes.