October 3, 2016
Configuring connectors with Apache Virtual Hosts in ColdFusion (2016 release)
Comments
(10)
October 3, 2016
Configuring connectors with Apache Virtual Hosts in ColdFusion (2016 release)
Staff 10 posts
Followers: 2 people
(10)

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:

  1. Navigate to cf_root/cfusion/runtime/bin
  2. 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.

  1. Create the connector with Instance1 using the command (mentioned in Scenario 1). This step creates the connector-related files in the cf_rootconfigwsconfig1 folder.
  1. 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.

  1. Add the configurations below for each instance of server in workers.properties file:

For server Instance1

worker.Instance1.host=localhost

worker.Instance1.port=8017

For server Instance2

worker.Instance2.host=localhost

worker.Instance2.port=8018

For server Instance3

worker.Instance3.host=localhost

worker.Instance3.port=8019

 

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.

                          

 

  1. 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).

 

Screenshot 1:

 

Screenshot 2:

 

Screenshot3:

 

  1. 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):

JkMountFile "/opt/coldfusion2016/config/wsconfig/1/uriworkermap1.properties"

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:

JkMountFile "/opt/coldfusion2016/config/wsconfig/1/uriworkermap2.properties"

Add this path in Website3:

JkMountFile "/opt/coldfusion2016/config/wsconfig/1/uriworkermap3.properties"

 

Now, go ahead and verify your setup and website.

 

Note:

  • 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.

 

10 Comments
2017-01-22 23:03:46
2017-01-22 23:03:46

This config not proper done. I have test on cf2016. Not working.

Like
2016-10-19 05:36:35
2016-10-19 05:36:35

@GC, thanks

@Wil, on a dev box, you can let the “Indexes” enabled. However, on a production server, you should disable it. This article is written, using the default attributes and values, given in Apache/ColdFusion configuration files.

Like
2016-10-09 06:37:09
2016-10-09 06:37:09

Thank you for this info. I’ll have to experiment with this config a bit. I’m pretty sure it won’t resolve my config issue of having a dev box with multiple CF versions configured. I currently need to swap out the mod_jk file when I shutdown one version and start another version. But it does help me solve a production CF2016 Enterprise config issue.

I do have one question on a security item. Why is the option “Indexes” enabled? This makes the Browsable and shows the file contents. For example this url https://www.example.com/cf_scripts/ for your domain would display all the files and folders and they are browsable and clickable. Wouldn’t a better security option be to not include the Option Indexes?

This
Alias /cf_scripts “/opt/coldfusion2016/cfusion/wwwroot/”

Options Indexes FollowSymLinks
AllowOverride None
Require all granted

Vs. this
Alias /cf_scripts “/opt/coldfusion2016/cfusion/wwwroot/”

Options FollowSymLinks
AllowOverride None
Require all granted

This is the same for the mod_jk.conf in ColdFusion 10 and ColdFusion 11 as well.

Like
2016-10-06 00:27:35
2016-10-06 00:27:35

Hey Vikram,

I do this in my local environment, in a separate config that defines all my virtual hosts.

# Copy over any JkMountfile to all Virtual Hosts

JkMountCopy All

Like
2016-10-04 09:48:59
2016-10-04 09:48:59

@Charlie, below are the default values for maxThreads and ConnectionTimeout parameter in “server.xml” and it remains same across all the platform.

maxThreads=500
connectionTimeout=60000

Like
2016-10-04 07:47:59
2016-10-04 07:47:59

@Charlie, thanks for the detailed review.

You are correct. The connection_pool_size or max_reuse_connections in the workers.properties file are not there in CF2016 on non-windows environment. There is an internal bug, which will be fixed in upcoming update of CF2016. What I have shown in my screenshots, is the default in RHEL environment.

Also, just to clarify, this is not the blog for Connector tuning with Apache. We will certainly have one, on those grounds, soon.

As far as the “changes regarding the connector configuration in 2016” are concerned, this is certainly important. I have passed this to our documentation team.

@ Hiroki & Tom, yes there are different ways to implement the same. You can choose the one, convenient for you and as per the standards.

Like
2016-10-04 00:37:48
2016-10-04 00:37:48

Hiroki is right, that is a better solution.

And *if* you are going to decide to put the same line of config in many hosts, put it in it’s own .conf file and include it – I think this is a fairly basic rule of maintainable configuration files.

Like
2016-10-03 19:24:19
2016-10-03 19:24:19

IMHO, it’s simpler to add “JkMountCopy On” to the virtual hosts or “JkMountCopy All” to the global configuration in scenario 1.

Like
2016-10-03 13:37:16
2016-10-03 13:37:16

[Subscribe]

Like
2016-10-03 13:34:10
2016-10-03 13:34:10

(subscribe)

Like
Add Comment