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_root\config\wsconfig\1 folder.
  1. Add the server names to worker list in workers.properties located in cf_root\config\wsconfig\1 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_root\instance_name\runtime\conf\.

                          

 

  1. Create the file uriworkermap.properties for each instance of ColdFusion at the location cf_root\config\wsconfig\1. 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_root\config\wsconfig\1 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.

 

15 Comments to “Configuring connectors with Apache Virtual Hosts in ColdFusion (2016 release)”

  1. Sandip Halder
    (subscribe)
  2. Rahul
    [Subscribe]
  3. Charlie Arehart
    Vikram, thanks for this. I'm sure it will help many who've wondered about such things. Still, I'm curious about a couple of things

    First, your screenshots show no value being set for connection_pool_size or max_reuse_connections in the workers.properties file.

    In CF2016, with IIS at least, when the wsconfig tool runs, it creates a workers.properties that has both the connection_pool_size and max_reuse_connections values set (as well as the connection_pool_timeout, which you do show), all of which is a nice improvement over CF10 and 11, where only the max_reuse_connections was set, leaving the other two to default (with connection_pool_timeout defaulting to an infinite timeout).

    So can you confirm, since I don't have an RHEL environment handy: is what you're really seeing as the defaults one gets (only connection_pool_timeout set) with the wsconfig tool run against Apache in RHEL?

    Second, I'm sure some readers of the blog here, seeing your title of this post, may have been hopeful that this would finally be the blog post from Adobe which offered the Apache perspective (for Linux or Windows) to the posts here from Adobe in 2014 (for CF10) and 2012 (for CF10) regarding tuning these settings for IIS (these workers.properties settings and the maxThreads and connectionTimeout settings in server.xml).

    Indeed, your post is silent on those settings entirely (which could leave some wondering about them).

    Finally, there's been no post from Adobe yet on other important changes regarding the connector configuration in 2016 (the new defaults, new aspects of the wsconfig UI or command line, etc.). That could be a helpful adjunct to these 3 other posts.

    At a minimum, though, can you or anyone from Adobe share thoughts on the tuning of the settings above, and how things may be different in Apache vs what was discussed in those older blog posts? Thanks.
  4. Hiroki Taniura
    IMHO, it's simpler to add "JkMountCopy On" to the virtual hosts or "JkMountCopy All" to the global configuration in scenario 1.
  5. Tom Chiverton
    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.
  6. Vikram
    @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.
  7. Charlie Arehart
    Thanks so much, Vikram.
  8. Charlie Arehart
    Hey Vikram, I should have asked in my last comment: can you confirm what the server.xml maxThreads and connectionTimout values are by default in your configuration?

    And your previous point (about the lack of new default settings for connection_pool_size or max_reuse_connections in workers.properties) indicated these were lacking in Apache. Is that (and whatever defaults you may report to my question above) about Apache on Linux only, or also on Windows?

    Again, it's easier for me to ask then to setup examples of each to test. :-) And it would benefit some readers to know, thanks.
  9. Vikram
    @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
  10. Charlie Arehart
    Vikram, ok great. Thanks for the confirmation, and good to see.
  11. Giancarlo Gomez
    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
    <IfModule jk_module>
       JkMountCopy All
    </IfModule>
  12. Wil Genovese
    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 <Directory path> 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/"
    <Directory "/opt/coldfusion2016/cfusion/wwwroot/">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
    </Directory>

    Vs. this
    Alias /cf_scripts "/opt/coldfusion2016/cfusion/wwwroot/"
    <Directory "/opt/coldfusion2016/cfusion/wwwroot/">
    Options FollowSymLinks
    AllowOverride None
    Require all granted
    </Directory>

    This is the same for the mod_jk.conf in ColdFusion 10 and ColdFusion 11 as well.
  13. Anit
    @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.
  14. John Smith
    This config not proper done. I have test on cf2016. Not working.
  15. Charlie Arehart
    John, it's understandable to be frustrated when connector issues happen, but it could be simply that it didn't work for a reason unique to your situation which can be explained.

    How about sharing whatever error or unexpected result you're getting, and what if anything you've done to diagnose that. Perhaps Adobe or others could then better help rectify your issue.

    Let us know also if you have been able to reverse the changes so that things are back to working for you as before. Besides helping us know how urgent this is for you, it could be diagnostically useful information.

Leave a Comment

Leave this field empty: