FairCom products include an application server that provides HTTP and WebSocket services, such as FairCom's REST API, JSON NAV API, and its browser-based web applications, such as SQL Explorer, Monitor, and MQ Explorer. See Configuring the Browser-Based Tools in the Browser-Based Tools guide.
To change the ports used by the application server, edit the file cthttpd.json located in the folder <faircom-Installation>\server\config.
If you have a port conflict, you can change the port to an unused port. FairCom recommends you disable insecure HTTP connections (see below).
For example, FairCom's web applications and REST API are configured to listen for HTTP connections on port 8081 and HTTPS connections on port 8443. JSON NAV API is configured to listen on port 8081. MQTT is configured to listen on port 1883.
In Version 12.5 and later, the configuration file contains the following JSON:
{
"tls_certificate": "./web/fccert.pem",
"http_port": 8080,
"http_enabled": true,
"https_port": 8443,
"https_enabled": true,
"websocket_port": 8081,
"websocket_tls_connections_only": true,
"websocket_enabled": true,
"mqtt_port": 1883,
"mqtt_tls_connections_only": false,
"mqtt_enabled": true,
"app_root": "./web/apps",
"http_url_to_appserver_map": [
"mqtt;ctmqtt.dll",
"ctree;ctrest.dll",
"AceMonitor;ctmonitor.dll",
"SQLExplorer;ctsqlexplorer.dll",
"ISAMExplorer;ctisamexplorer.dll"
],
"websocket_url_to_appserver_map": [
"json_nav;json_nav.dll"
]
}
You can add the following security settings to cthttpd.json.
{
"access_control_list": "-0.0.0.0/0,+192.168/16",
"auth_domain": "mydomain.com",
"global_auth_file": "./web/passFile",
"ssi_pattern": "**.shtml$|**.shtm$",
"tls_certificate": "./web/fccert.pem",
"tls_key": "SSL private key",
"tls_ca": "SSL Certificate Authority",
"tls_cipher_suites": "Allowed SSL cipher suites (colon-separated list)"
}
You can add the following web server settings to cthttpd.json.
{
"web_thread_count": 10,
"document_root": "./web/apps",
"url_rewrites": "**.doc$=/path/to/cgi-bin/handle_doc.cgi",
"index_files": "index.html,index.htm,index.shtml,index.cgi,index.php,index.lp",
"hide_files_patterns": "secret.txt|even_more_secret.txt",
"extra_mime_type": ".cpp=plain/text,.java=plain/text",
"hexdump_file": "./web/hexDumpFile",
"cgi_interpreter": "#!/path/to/php-cgi.exe",
"cgi_pattern": "**.cgi$|**.pl$|**.php$"
}
The web server options allow you to deliver your own browser-based applications and services. Contact FairCom to learn more before changing these options because they may interfere with the built-in web applications and services. In addition, contact FairCom if you have specific requirements not covered with these options.
You can add the following database connection settings to cthttpd.json.
{
"linked_ace_server": "FAIRCOMS@localhost"
}
The "linked_ace_server" property specifies the database that the application server connects to. If it is omitted, it defaults to "FAIRCOMS@localhost", which causes the application server to connect to the database named FAIRCOMS that is running on the same computer as the application server. If you want the application server to connect to a database on another computer or to connect with a database that has a different name than FAIRCOMS, you can change the value of this property.
In FairCom product versions prior to 12.5, the configuration file contains the following JSON:
{
"listening_https_port": 8443,
"ssl_certificate": "./web/fccert.pem",
"document_root": "./web/apps",
"mqtt_enabled": true,
"mqtt_listening_port": 1883,
"mqtt_persistence_enabled": true,
"mqtt_log_enabled": false,
"mqtt_websocket_port": 8081,
"mqtt_websocket_ssl_enabled": true,
"mqtt_statistics_interval": 5,
"applications": [
"mqtt;ctMQTT.dll",
"ctree;ctREST.dll"
]
}
"listening_http_port": 8081 - Sets the port number used by the HTTP server for the REST API and browser-based tools. 8081 is the default; you can change it to any available port. (with the exception of the database engine's already two configured ports).
A list of ports is provided in Download and Installation.
Additional options can be configured including secure TLS configurations (recommended). Contact FairCom if you have specific requirements not covered with these options.
{
"access_control_list": "-0.0.0.0/0,+192.168/16",
"auth_domain": "mydomain.com",
"cgi_interpreter": "#!/path/to/php-cgi.exe",
"cgi_pattern": "**.cgi$|**.pl$|**.php$",
"document_root": "./web/apps",
"extra_mime_type": ".cpp=plain/text,.java=plain/text",
"global_auth_file": "./web/passFile",
"hide_files_patterns": "secret.txt|even_more_secret.txt",
"hexdump_file": "./web/hexDumpFile",
"index_files": "index.html,index.htm,index.shtml,index.cgi,index.php,index.lp",
"listening_http_port": 8080,
"listening_https_port": 8443,
"ssi_pattern": "**.shtml$|**.shtm$",
"ssl_certificate": "./web/fccert.pem",
"url_rewrites": "**.doc$=/path/to/cgi-bin/handle_doc.cgi",
"web_thread_count": 10,
"mqtt_enabled": true,
"mqtt_listening_port": 1883,
"mqtt_persistence_enabled": true,
"mqtt_log_enabled": false,
"mqtt_conn_inactive_timeout": 60,
"mqtt_conn_request_timeout": 20,
"mqtt_max_dbconn_count": 30,
"application": [
"mqtt;ctMQTT.dll",
"ctree;ctREST.dll",
"AceMonitor;ctMonitor.dll",
"SQLExplorer;ctSQLExplorer.dll",
"ISAMExplorer;ctISAMExplorer.dll",
"OpsManager;ctMemphis.dll"
],
"linked_ace_server": "FAIRCOMS@localhost"
}
Advanced SSL Certificate Options
The ssl_certificate keyword in the config/cthttpd.json web server plug-in configuration supports the fccert.pem, which is a self-signed certificate we supplied. To use your own certificate, use the following keywords to config/cthttpd.json:
Default linked_ace_server
The HTTP Plug-in (cthttpd, the Web Server Plug-in) supports connecting to a remote c-tree server. The engine to be used by the web server is configured by the linked_ace_server property in cthttpd.json. That option allows you to specify which c-tree server to use for the REST API, MQTT persistence, etc. The default linked_ace_server is NULL, which means FAIRCOMS@localhost. To change this default, change this property in cthttpd.json.
Because the default usage of cthttpd is by the HTTP Plug-in (the Web Server Plug-in loaded by a c-tree server), the plug-in framework already has the "caller" server name in the plug-in structure. So, instead of considering the default linked_ace_server as NULL, we now assume the local server name as default.
Note that if linked_ace_server is configured in cthttpd.json, it will overwrite this local server name as default.
To dynamically load a plug‑in on demand after c-tree Server has started up, use the ctadmn utility or use the same PLUGIN configuration option syntax that you would use in ctsrvr.cfg in a call to ctSETCFG().
Example 1 ‑ ctadmn utility:
10. Change Server Settings
Enter the configuration option and its value:
>> PLUGIN cthttpd;./web/cthttpd.dll
Successfully changed the configuration option.
Example 2 ‑ API function call:
ctSETCFG(setcfgCONFIG_OPTION, "PLUGIN cthttpd;./web/cthttpd.dll");