ColdFusion (2016 release) has a webserver configuration tool for creating connectors with external web servers. These connectors work with Apache and IIS webservers. You can create one single connector (ALL) to run with all your websites or create individual connectors (ALL-Individually) for each website. We have seen scenarios, where users use “Virtual Host” to run multiple websites on a single server, in Apache.
In this blog, we will see, how to configure ColdFusion connector to work with multiple Virtual hosts in Apache and map the virtual hosts with individual instance of ColdFusion.
Note: – This blog is written, in context of Apache being installed in an RHEL environment.
Scenario 1: Configuring connector to run with multiple Virtual hosts
Unlike IIS, we don’t have the option to select multiple websites, when we run the Web Server Configuration tool or WSCONFIG tool. To achieve this, we will have to create a connector with Apache, which will have multiple websites (Virtual hosts). Assuming that we have already installed ColdFusion (2016 release) and Apache, we shall go ahead and create the connectors with Apache.
To create a connector in ColdFusion (2016 release) with Apache in RHEL, please follow the below:
- Navigate to cf_root/cfusion/runtime/bin
- Enter the command
sudo ./wsconfig -ws Apache -bin /usr/sbin/httpd -script /usr/sbin/apachectl -dir /etc/httpd/conf/ -v
Note: The above command assumes pre-configured Apache in RHEL environment, command line switches and path for binaries may change across different flavors of Unix (Reference article).
Once you have created the connector successfully, ColdFusion creates a file mod_jk.conf in the location /Apache_root/conf/ (/etc/httpd/conf/ in this example).
To configure the connector and run multiple Virtual hosts, copy the JKMountFile path entry from mod_jk.conf file and add it to each of the Virtual Host blocks. For example, refer to the screenshot below:
Add the entry JkMountFile "/opt/coldfusion2016/config/wsconfig/1/uriworkermap.properties" and add it to each Virtual Hosts in /etc/httpd/conf/httpd.conf, as highlighted below:
Scenario 2: Configure Apache virtual host for each ColdFusion instance
Consider the scenario where you have three virtual hosts that need to be run independently, and are not to be served by a single instance of ColdFusion.
To achieve this, you require three instances of ColdFusion server. Each server instance has separate settings. For example, let there be three instances of ColdFusion servers Instance1, Instance2, and Instance3 to be configured with three virtual hosts Website1, Website2, and Website3 respectively.
- Create the connector with Instance1 using the command (mentioned in Scenario 1). This step creates the connector-related files in the cf_rootconfigwsconfig1 folder.
- Add the server names to worker list in workers.properties located in cf_rootconfigwsconfig1 folder. Add Instance1, Instance2, and Instance3 to the parameter worker.list.
- Add the configurations below for each instance of server in workers.properties file:
For server Instance1
For server Instance2
For server Instance3
Note: Instance* is the AJP/1.3 port number associated with individual server instance that can be found in server.xml at cf_rootinstance_nameruntimeconf.
- Create the file uriworkermap.properties for each instance of ColdFusion at the location cf_rootconfigwsconfig1. In this example, you require three copies of uriworkermap.properties file (name it as – uriworkermap1.properties, uriworkermap2.properties, and uriworkermap3.properties).
4.1 Copy the content of uriworkermap.properties in cf_rootconfigwsconfig1 to uriworkermap1.properties, uriworkermap2.properties, and uriworkermap3.properties.
4.2 Replace the instances with the corresponding servers: –
- In uriworkermap1.properties, all the entries for server name will become “Instance1” (Screenshot 1),
- uriworkermap2.properties will have “Instance2” as server name (Screenshot 2)
- uriworkermap3.properties will have “Instance3” as server name (Screenshot 3).
- Define the URI mappings associated with each server instance in virtual host configuration to run the websites independently.
To run Website1 on server instance "Instance1", add the JKMountFile path as mentioned below in virtual host configuration (/etc/httpd/conf/httpd.conf):
Notice that uriworkermap1.properties file contains URI mappings for Instance1.
Similarly, add the JKMountFile path for Website2 and Website3 that contain URI mappings for server instances "Instance2" and "Instance3".
Add the path in Website2:
Add this path in Website3:
Now, go ahead and verify your setup and website.
- Any changes made to connector files requires an Apache restart for the changes to take effect.
- Any changes made to httpd.conf file within Apache, requires an Apache restart for the changes to take effect.