Saturday, May 23, 2015

WSO2 BAM behind reverse proxy using Apache HTTP Server

When you deploy WSO2 BAM in production, you often need to deploy it behind a proxy server or load balancer. We will see how to configure BAM behind Apache HTTP Server as reverse proxy.

Apache HTTP Server Configuration


  • Install and configure Apache HTTP server
  • Enable following modules using a2enmod
  • Run the following command
  • Create a certificate and a key for Apache HTTP server. You will use these when you define a new virtual host
  • Add the following entries to your */etc/hosts* file
  • Create a virtual host like below. You can add this to /etc/apache2/sites-available/default-ssl.conf file
  • Restart Apache HTTP server

 

BAM Configuration


  • Uncomment and modify both HostName and MgtHostName in $BAM_HOME/repository/carbon.xml
  • Uncomment and modify ProxyContextPath in $BAM_HOME/repository/carbon.xml

Now you should be able access the BAM using following URLs

Management console - https://bamproxy.example.com/bamcarbon
Message console - https://bamproxy.example.com/messageconsole
Activity monitoring - https://bamproxy.example.com/activitymonitoring
BAM dashboards - https://bamproxy.example.com/bamdashboards

WSO2 ESB - Logging VFS Transport Logs to a Different Log File

If you enable DEBUG logs for VFS transport, it might poison the default wso2carbon.log file. Instead, you can do the following configurations to write VFS transport logs to a different log file, while these logs won't be written to default wso2carbon.log

  1. Add the following configurations to $ESB_HOME/repository/conf/log4j.properties file
  2. log4j.logger.org.apache.synapse.transport.vfs=DEBUG, CARBON_VFS_LOGFILE
    log4j.additivity.org.apache.synapse.transport.vfs = false
     
    log4j.appender.CARBON_VFS_LOGFILE=org.wso2.carbon.logging.appenders.CarbonDailyRollingFileAppender
    log4j.appender.CARBON_VFS_LOGFILE.File=${carbon.home}/repository/logs/${instance.log}/wso2carbon-vfs${instance.log}.log
    log4j.appender.CARBON_VFS_LOGFILE.Append=true
    log4j.appender.CARBON_VFS_LOGFILE.layout=org.wso2.carbon.utils.logging.TenantAwarePatternLayout
    log4j.appender.CARBON_VFS_LOGFILE.layout.ConversionPattern=TID: [%T] [%S] [%d] %P%5p {%c} - %x %m {%c}%n
    log4j.appender.CARBON_VFS_LOGFILE.layout.TenantPattern=%U%@%D [%T] [%S]
    log4j.appender.CARBON_VFS_LOGFILE.threshold=DEBUG
    
    
  3. Restart ESB
  4. A new wso2carbon-vfs.log file will be created in $ESB_HOME/repository/logs directory.