Scenario 2: Double Termination
In this example, we setup both SSL Proxy Termination and Backend Termination. Replicate the certificate information mu on every backend server, and manage the certificate on the Proxy.

Configure Both HA Proxy and Data Hub with SSL Termination
Steps Performed on the Data Hub Server.
Add the following lines to your local.properties file, replacing <password> with the configured password for the user.
datahub.security.https.enabled=true datahub.server.url=https://localhost:8443/datahub-webapp/ datahub.security.basic.admin.user=<password> datahub.security.basic.admin.password=<password>
Add the following lines to your Tomcat 8.5.x server.xml file.
<Connectorf protocol="org.apache.coyote.http11.Http11NioProtocol" port="8443" maxThreads="200" scheme="https" secure="true" SSLEnabled="true" keystoreFile="/opt/tomcat/conf/datahub.jks" keystorePass="123456" clientAuth="false" sslProtocol="TLS"/>
Configure the Java Cryptography Extension (JCE) Provider
To enable higher crypto security in Java 7 and 8, lift the 1024-bit long prime restriction on Diffie-Hellman. Follow the steps at https://docs.oracle.com/cd/E19830-01/819-4712/ablsc/index.html
.
-
Download these jars:
-
Move these jars to $JAVA_HOME/lib/ext
-
Edit $JAVA_HOME/lib/security/java.security as follows: security.provider.1=org.bouncycastle.jce.provider.BouncyCastleProvider
Restart the application using JRE.
Update for the JCE Security Policy
Update your JCE Security Policy files to have an effective configuration.
-
Download the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 8 Download zip. http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html
. -
Extract the file from the zip. unzip jce_policy-8.zip.
-
Copy the jars. cp /usr/lib/jvm/java-1.8-openjdk/jre/lib/security/UnlimitedJCEPolicyJDK8/*.jar $JAVA_HOME/jre/lib/security/.
-
Set the security on the directory. chmod -R 640 $JAVA_HOME/jre/lib/security/.
HAProxy Steps Performed on the HAProxy Server
global
chroot /var/lib/haproxy
#log /dev/log local0
#log /dev/log local1 notice
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
# Default ciphers to use on SSL-enabled listening sockets.
# For more information, see ciphers(1SSL). This list is from:
# https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
ssl-default-bind-options no-sslv3
ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS
ssl-default-server-options no-sslv3
ssl-default-server-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS
tune.ssl.default-dh-param 2048
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
############################
# Scenario 2 Configure both HA Proxy and Data Hub with SSL Termination
############################
frontend https_termination_front_to_http_back
mode http
bind *:9798 ssl crt /etc/ssl/datahubcrtkey.pem
#stats uri /haproxy?stats
default_backend http_back
backend http_back
mode http
balance roundrobin
# admin admin:<password>
option httpchk GET /datahub-webapp/v1/status HTTP/1.0\r\nAuthorization:\ Basic\ YWRtaW46c2VjcmV0
server node1 172.17.0.1:8080 check
server node2 172.17.0.2:8080 check
server node3 172.17.0.3:8080 check
http-check expect string Running
############################
listen stats
bind *:8181
stats enable
stats uri /
stats realm Haproxy\ Statistics
stats auth admin:<password>
Add SSL Key and Certificate
Copy your pem into the same directory as stated after your bind in the haproxy.cfg.
Example from the haproxy.cfg line 31
bind *:9798 ssl crt /etc/ssl/datahubcrtkey.pem
So, copy your pem into /etc/ssl/.
Test the Double Termination
To make sure the double termination is working, test it by doing a curl to the Data Hub through Double Termination, replacing <password> with the password configured for the user.
curl -k -v --insecure --user admin:<password> https://<haproxyIP>:9798/datahub-webapp/v1/status
The output of curl should include HTTP/1.1 200 OK
Conclusion
You have finished setting up both SSL Proxy Termination and Backend Termination. Remember, the certificate information must be replicated on every backend server, and you must manage the certificate on the Proxy.