Target Page
The target page (typically, DiscoverUIPost.php) is the endpoint where visitor session data is posted to via the deployed JavaScript SDK (typically, discoverUI.js). A copy of this file can be located in the downloaded installation package.
There are many options and approaches available for hosting the target page within the Discover solution environment. Approaches used will vary depending on project requirements, infrastructure constraints, platform (e.g., cloud), and many others.
The default deployment option of hosting the target page on the DNCA server and leveraging the existing default Apache HTTP instance is described in the steps below.
Pre-target page configuration
-
Create a new folder by issuing the command,
mkdir /var/www. -
Locate and copy the DiscoverUIPost.php file to the location above. Edit and modify the contents of the DiscoverUIPost.php file as below, set
$DCX_MAX_REQ_LENGTHvalue to 15000000; -
Create and save a .htaccess file that contains the following to the location above. Update the your-domain-name.com value:
.htaccess file<IfModule mod_headers.c> SetEnvIf Origin "http(s)?://(www\.)?(your-domain-name.com)$" AccessControlAllowOrigin=$0 Header add Access-Control-Allow-Origin %{?AccessControlAllowOrigin}e env=AccessControlAllowOrigin Header set Access-Control-Allow-Credentials true Header set Access-Control-Allow-Headers "*" </IfModule>Configure HTTPD
-
Using the following command, vi /usr/local/dncauser/etc/httpd.conf configure the Apache web server to serve the DiscoverUIPost.php page.
-
Add the below entries to the httpd.conf file. The ServerName and ServerAlias should be set to the hostname (or FQDN) of the DNCA server. Additionally, the DocumentRoot and Directory directives should be set to the location where the DiscoverUIPost.php file is located.
httpd.conf fileListen 80 NameVirtualHost *:80 <VirtualHost *:80> ServerName localhost.localdomain ServerAlias localhost.localdomain DocumentRoot /var/www/ <Directory /var/www/> Satisfy Any </Directory> ErrorLog /var/log/discover/error.log </VirtualHost>Info
It is recommended that SSL Offload is carried out prior to reaching the Discover servers at a load balancer or similar on the infrastructure. However, sometimes there is a need to do the SSL Offload on the DNCA server itself. This can be done with the following config items:
httpd.conf file for SSLNote that the dncaCert.crt and dncaCert.key need to reflect the domain SSL certificatesListen 443 NameVirtualHost *:443 <VirtualHost *:443> ServerName localhost.localdomain ServerAlias localhost.localdomain SSLEngine on SSLProtocol -All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1 +TLSv1.2 SSLCipherSuite ALL:!EDH:!DHE:!DH:!ECDH:!ADH:!EXP:!DHE:!EDH:!RC4:+HIGH:+MEDIUM:!SSLv2:!SSLv3:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK SSLCertificateFile /var/www/dncaCert.crt SSLCertificateKeyFile /var/www/dncaCert.key DocumentRoot /var/www/ <Directory /var/www/> Satisfy Any </Directory> ErrorLog /var/log/discover/error.log </VirtualHost> -
Grant the DNCA processes permissions to open the port 443 that will serve the DiscoverUIPost.php page by issuing the command:
setcap CAP_NET_BIND_SERVICE=+eip /usr/local/dncauser/bin/httpd -
Restart the DNCA httpd processes by issuing the following commands,
discover stop httpdanddiscover start httpd.
Optional configuration
The following optional configuration is dependent on the project requirements and or infrastructure to Allow cross-origin posts
-
If required, edit the DiscoverUIPost.php and comment out the below entry header ("Access-Control-Allow-Origin: *"); by adding a // at the start of the line.
-
Create a new file named .htaccess (note the dot character in front of the file name) in the DocumentRoot folder (as defined in the httpd.conf, under the virtualhost definition for the DiscoverUIPost page).
-
Add the code below into the .htaccess file, customising the list of domains matching project FQDN requirements. In the example below the are several domains listed, separated by an or "|" denotation; update the SetEnvIf Origin"to include any additional domains.
.htaccess file<IfModule mod_headers.c> SetEnvIf Origin "http(s)?://(www\.)?(discoverstore.hclcx.com|dx-roedemo1.team-q-dev.com:10039|mydomain.com|myotherdomain.org)$" AccessControlAllowOrigin=$0 Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin Header set Access-Control-Allow-Credentials true Header set Access-Control-Allow-Headers "*" </IfModule> -
Restart the DNCA httpd processes by issuing the following commands,
discover stop httpdanddiscover start httpd.
Success
The DNCA server is now serving the Discover target page.
Info
Depending upon the status of the SDK deployment, you may wish to stop the Discover httpd process receiving traffic until other servers have been installed, configured, and made available.
Certificate
The following steps of generating a self-signed SSL certificate are not suitable for a production or non-production level environment and should only be used for personal training or local testing level environments exercises.
Correctly signed certificates should always be implemented for production and non-production (dev/test/UAT/etc ..) environments. If unsure speak with your organisations IT management or assigned lead architect.
-
Generate a self-signed SSL certificate by issuing the following at the command line. When prompted for the Common Name, specify the exact hostname / FQDN of the DNCA Linux server
openssl req -x509 -nodes -sha256 -days 365 -newkey rsa:2048 -keyout myCert.key -out myCert.crt. -
Verify or review the contents of the generated certificate by issuing the command
openssl x509 -in test.crt -text -noout. -
Copy and upload the newly created SSL certificate files
myCert.crtandmyCert.keyto the folder created in step 1. -
Change the ownership for both files by issuing the following command
chown dncauser:dncauser myCert.*. -
Create a PEM file to store the certificate keys created in step 4 by issuing the command,
cat myCert.key myCert.crt > myCert.pem -
Move or copy the resulting .pem file by issuing the following command,
mv myCert.pem /usr/local/dncauser/etc/capturekeys/.Tip
Copies of certificates / keys for backup purposes should be stored as per your organisation's standards.
-
Restart the DNCA processes by issuing the following commands,
discover stop all,discover statusanddiscover start all. -
At this point the /usr/local/dncauser/etc/capturekeys/myCrt.ptl file should have been created, validate this has occurred and then the .pem file from steps 8 and 9 may be deleted or renamed.