Oracle Autonomous AI Database Serverless (ADB-S) uses Oracle domain names and certificates for database connections. You connect using the hostname and service name provided by ADB-S and your client verifies the certificate when it establishes Transport Layer Security (TLS).

But… what if you want to use your own domain name and TLS certificate? You can put HAProxy in front of ADB-S. Your application connects to the proxy using your hostname and the proxy connects to ADB-S using its original Oracle hostname.

In this blog, you will learn how to set that up for an existing ADB-S private endpoint. We’ll install your certificate on an Oracle Cloud Infrastructure (OCI) Compute virtual machine (VM) running HAProxy. If you don’t have a certificate the steps to create one are included.

How the connection works

Your client connects to the proxy on port 1541 and checks your certificate. HAProxy then opens a second TLS connection to ADB-S on port 1521 and checks Oracle’s certificate. The database still authenticates your database user so you don’t put a database password in the HAProxy configuration.

Both connections are encrypted, but they are separate TLS sessions. HAProxy decrypts and re-encrypts traffic in-memory. You’ll need to treat the proxy VM as a trusted part of your application environment.

Before you start

This blog uses OCI. You will need an existing ADB-S private endpoint and an OCI Compute VM that can reach it. You’ll also need Secure Shell (SSH) access to the VM, database credentials, and permission to update OCI network rules. HAProxy doesn’t need to be preinstalled (We will install it later).

The instructions distinguish the proxy VM, the administrator workstation, and the client. The workstation and client can be the same computer.

I’ll use db.example.com throughout the examples. Replace it with your chosen hostname in the commands, certificate, and client settings. You can use a Domain Name System (DNS) record under a domain you own or a hosts-file entry. Keep the original hostname and service name provided by Oracle Autonomous AI Database (ADB) unchanged.

Replace these placeholders throughout the examples before running commands. Placeholders are documentation notation, not shell variables.

PlaceholderMeaning
<PROXY_PUBLIC_IP>Public IP assigned to the VM.
<PROXY_PRIVATE_IP>VM private IP in the proxy subnet.
<ADMIN_PUBLIC_IP>Administrator’s public egress IPv4 address for SSH.
<CLIENT_PUBLIC_IP>Client’s public egress IPv4 address.
<SSH_KEY>Path to the private SSH key on the user’s machine.
<ADB_HOST>Original private endpoint hostname copied from ADB-S.
<ADB_SERVICE_NAME>Complete service name from ADB-S TLS connection string.
<CLIENT_CA_BUNDLE>Client side PEM file containing trusted issuing CA certificates.
<ACTIVE_ZONE>Firewalld service zone associated with the VM network interface.

1. Verify Connection details

In the OCI Console, open the Autonomous AI Databases list. Select the region and compartment containing your database, then click its name to open the details page. We’ll use this existing database and its private endpoint.

Check the Require mutual TLS authentication setting in ADB. It must be disabled for this example because HAProxy won’t present a client certificate to ADB. This still gives us an encrypted connection with server certificate validation. Follow your normal change process if the setting needs to be changed.

Open Database Connection, select TLS. Copy the descriptor for your service, such as _low. Record the hostname, port, and full service name. Keep ssl_server_dn_match=yes. These examples use port 1521. Substitute 1522 throughout if your descriptor uses it.

2. Verify proxy network access

Before we add the proxy, let’s check that traffic can reach both ends. For this example, the VM needs a public IP and a route through an Internet Gateway. Its connection to ADB uses the private endpoint, so the database subnet stays private.

An OCI network security group (NSG) defines traffic rules for its associated resources. We’ll use one for the proxy VM and one for the private endpoint of ADB.

In the OCI Console, open Networking → Virtual Cloud Networks and select your virtual cloud network (VCN). Open Network Security Groups, under Security. Create NSGs named proxy-nsg and adb-nsg. Both must be in the same VCN.

Open each group and its security rules. Add the following Ingress rules:

  • Set IP Protocol to TCP.
  • Leave Source Port Range as All.
  • Leave Stateless unchecked.
  • In Destination Port Range, enter only the port number shown in the table below.
  • For the proxy rules, choose CIDR as the source type.
  • For ADB access, choose Network Security Group and select proxy-nsg.
NSGSourceDestination portPurpose
proxy-nsg<ADMIN_PUBLIC_IP>/3222SSH administration.
proxy-nsg<CLIENT_PUBLIC_IP>/321541Client access to HAProxy.
adb-nsgproxy-nsg1521Proxy access to ADB.

Now associate the groups with their resources:

  1. Proxy VM: Open Compute → Instances → your VM → Networking → Attached VNICs. Select the VNIC carrying the proxy IP. Next to Network Security Groups, click Edit, add proxy-nsg, and save. Keep any existing groups needed by the VM.
  2. ADB: Return to the database details page. Under Network, find Network Security Groups and click Edit. Add adb-nsg and save, retaining any groups still needed.

Use the public egress IP of the administrator for SSH and the client. They can be the same IP if both connections leave through the same public IP.

Check Security Lists for broader allow rules. Preserve rules needed by other workloads. Allow egress for ADB, DNS, and package downloads.

2.1 Verify backend connectivity

Connect to the VM. Record its private IP for <PROXY_PRIVATE_IP>:

ip -4 -brief address

Check ADB name resolution:

getent ahostsv4 <ADB_HOST>

You should get ADB private IP. Next, install the tools: OpenSSL and the Certificate Authority (CA) trust bundle.

sudo dnf install -y openssl ca-certificates
mkdir -p ~/adb-proxy-lab/tls
chmod 700 ~/adb-proxy-lab/tls

The folder will hold the certificate files we use later. If you create a certificate in section 4.2, we’ll use Customer Lab as its organization label and Customer Lab Root CA as the name of its private certificate authority.

Verify the Oracle certificate chain and hostname:

timeout 15 openssl s_client -brief \
  -connect <ADB_HOST>:1521 \
  -servername <ADB_HOST> \
  -verify_hostname <ADB_HOST> \
  -verify_return_error \
  -CAfile /etc/pki/tls/certs/ca-bundle.crt \
  </dev/null

Look for -> Verification: OK.

Test a direct SQL connection from the VM before adding HAProxy. Use the original ADB hostname and service. Getting this working first will make it easier to identify if a later problem lays on the proxy or on the database connection.

3. Prepare your custom domain

Now choose the name your application will use. If you have a domain, add a DNS record under it. Or, map your chosen hostname to the proxy IP in the client’s hosts file.

3.1 Option A: Use an existing domain

Choose a hostname under your domain, such as db.example.com. Ask the DNS administrator to create its record.

Add the DNS record

For external access, add an A record pointing to the proxy VM’s public IPv4 address:

FieldExample
TypeA
Namedb or db.example.com, depending on the provider
Address<PROXY_PUBLIC_IP>
TTLProvider default

3.2 Option B: Use a local name

Edit the hosts file on the computer that will connect to the database through HAProxy. For example, on a Linux client, open a terminal and edit /etc/hosts with administrator privileges:

sudo nano /etc/hosts

You can use another editor if you prefer. Add the following line, replacing <PROXY_PUBLIC_IP> with the proxy VM’s public IP and db.example.com with your chosen hostname:

<PROXY_PUBLIC_IP> db.example.com

Remove any conflicting entry for the same name. This mapping applies only to the computer where you edit the file.

3.3 Verify name resolution

For a DNS record

Query it from the client network/

nslookup db.example.com

For the local name entry

Use the operating system’s resolver e.g. on Linux:

getent ahostsv4 db.example.com

You should get the proxy IP.

4. Prepare the certificate and Configure HAProxy

Now, it is time to prepare the certificate for our name. The name must appear in the certificate’s Subject Alternative Name (SAN) field. That is what lets the client check that it reached the server it intended to reach.

If you already have a certificate from your approved CA, you can use it here. Otherwise, you can follow steps below to create a private CA and use it to sign a server certificate.

4.1 Install HAProxy

Run these commands on the VM:

sudo dnf install -y haproxy
haproxy -v

The second command prints the installed version.

4.2 Create a certificate

If you already have a certificate and its matching private key, skip to 4.3 Install the certificate.

We are going to create the server key on the VM and the CA on a separate administrator workstation. Only the certificate signing request (CSR) goes to the workstation for signing. The CA private key stays there. The client will later receive the CA’s public certificate so it can trust the server certificate.

Run these commands once for a new try. Re-running them can replace keys or certificates you’ve already created.

On the VM create the server key and CSR

These commands use db.example.com. If you chose another name in section 3, substitute it here and in server.ext below. Keep the file paths consistent if you rename the files too.

cd ~/adb-proxy-lab/tls
chmod 700 .
umask 077
openssl req -new -newkey rsa:3072 -noenc \
  -keyout db.example.com.key \
  -out db.example.com.csr \
  -subj '/O=Customer Lab/CN=db.example.com' \
  -addext 'subjectAltName=DNS:db.example.com'

On the administrator workstation create a CA:

mkdir -p ~/adb-proxy-lab-ca
cd ~/adb-proxy-lab-ca
chmod 700 .
umask 077
cat > ca.cnf <<'EOF'
[req]
prompt = no
distinguished_name = dn
x509_extensions = ca_extensions
[dn]
O = Customer Lab
CN = Customer Lab Root CA
[ca_extensions]
basicConstraints = critical,CA:TRUE,pathlen:0
keyUsage = critical,keyCertSign,cRLSign
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
EOF
openssl genrsa -aes256 -out customer-lab-ca.key 4096
openssl req -new -x509 -sha256 -days 365 \
  -key customer-lab-ca.key -out customer-lab-ca.crt -config ca.cnf

Choose a passphrase for the CA private key when prompted. Download only the CSR from the VM:

scp -i <SSH_KEY> \
  opc@<PROXY_PUBLIC_IP>:~/adb-proxy-lab/tls/db.example.com.csr .

On the same workstation, sign the request with the server extensions:

cat > server.ext <<'EOF'
basicConstraints = critical,CA:FALSE
keyUsage = critical,digitalSignature,keyEncipherment
extendedKeyUsage = serverAuth
subjectAltName = DNS:db.example.com
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
EOF
openssl x509 -req -in db.example.com.csr \
  -CA customer-lab-ca.crt -CAkey customer-lab-ca.key -CAcreateserial \
  -out db.example.com.crt -days 90 -sha256 -extfile server.ext
scp -i <SSH_KEY> db.example.com.crt customer-lab-ca.crt \
  opc@<PROXY_PUBLIC_IP>:~/adb-proxy-lab/tls/

On the VM, verify the resulting certificate:

cd ~/adb-proxy-lab/tls
openssl verify -CAfile customer-lab-ca.crt -purpose sslserver \
  -verify_hostname db.example.com db.example.com.crt

Expect db.example.com.crt: OK. These commands use OpenSSL’s CSR and certificate issuance facilities.

To use these files with the main procedure, on the VM run:

cp ~/adb-proxy-lab/tls/db.example.com.crt ~/adb-proxy-lab/tls/server-chain.crt
install -m 600 ~/adb-proxy-lab/tls/db.example.com.key ~/adb-proxy-lab/tls/server.key

We will use this certificate’s hostname for the client connection and TLS checks.

4.3 Install the certificate

No matter if you got your own certificate or created it, HAProxy needs the same two files on the VM:

FileContent
/home/opc/adb-proxy-lab/tls/server-chain.crtServer certificate, followed by any intermediates.
/home/opc/adb-proxy-lab/tls/server.keyMatching private key.

Protect the files on the VM:

chmod 700 ~/adb-proxy-lab/tls
chmod 600 ~/adb-proxy-lab/tls/server.key

On the VM, create a root readable PEM file containing the chain and server key:

sudo install -d -m 700 /etc/haproxy/certs
sudo sh -c 'umask 077; cat \
  /home/opc/adb-proxy-lab/tls/server-chain.crt \
  /home/opc/adb-proxy-lab/tls/server.key \
  > /etc/haproxy/certs/customer.pem'
sudo cp -n /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.original

4.4 Configure the proxy

Edit /etc/haproxy/haproxy.cfg on the proxy VM.

sudo nano /etc/haproxy/haproxy.cfg

Use this configuration if HAProxy will serve only this database proxy. If HAProxy already handles other connections, merge these sections into its existing configuration. Replace <PROXY_PRIVATE_IP> and <ADB_HOST> with your values. Keep the server adb directive on one line.

global
    log stdout format raw local0
    user haproxy
    group haproxy
    maxconn 100
    ssl-default-bind-options ssl-min-ver TLSv1.2
    ssl-default-server-options ssl-min-ver TLSv1.2

defaults
    log global
    mode tcp
    option tcplog
    timeout connect 10s
    timeout client 1h
    timeout server 1h

frontend customer_tls
    bind <PROXY_PRIVATE_IP>:1541 ssl crt /etc/haproxy/certs/customer.pem
    default_backend adb_tls

backend adb_tls
    server adb <ADB_HOST>:1521 ssl verify required ca-file /etc/pki/tls/certs/ca-bundle.crt sni str(<ADB_HOST>) verifyhost <ADB_HOST>

Allow HAProxy network access under SELinux and validate the configuration:

sudo setsebool -P haproxy_connect_any 1
sudo restorecon -Rv /etc/haproxy
sudo haproxy -c -f /etc/haproxy/haproxy.cfg

The sudo setsebool -P haproxy_connect_any 1 command allows HAProxy to connect to arbitrary ports under SELinux. The -P option makes the setting persistent. NSGs and firewall rules still apply. Oracle uses this setting in its HAProxy tutorial.

Only after configuration validation succeeds, start the service:

sudo systemctl enable --now haproxy
sudo systemctl status haproxy --no-pager -l

If HAProxy is already running, validate the configuration and reload it with sudo systemctl reload haproxy.

4.5 Let the client go through the VM firewall

There’s one more thing we need to verify on the VM. Its firewall needs to allow the client to reach port 1541, even if the OCI NSG already allows it.

Check whether firewalld is running:

sudo firewall-cmd --state

If it reports running, find the active zone and review its rules. If firewalld is inactive, these commands do not apply.

sudo firewall-cmd --get-active-zones
sudo firewall-cmd --zone=<ACTIVE_ZONE> --list-all
sudo firewall-cmd --permanent --zone=<ACTIVE_ZONE> --list-all

If a rule is needed, add it to the active interface’s zone. Apply it now and save it for restarts:

sudo firewall-cmd --zone=<ACTIVE_ZONE> \
  --add-rich-rule='rule family="ipv4" source address="<CLIENT_PUBLIC_IP>/32" port port="1541" protocol="tcp" accept'
sudo firewall-cmd --permanent --zone=<ACTIVE_ZONE> \
  --add-rich-rule='rule family="ipv4" source address="<CLIENT_PUBLIC_IP>/32" port port="1541" protocol="tcp" accept'
sudo ss -ltnp 'sport = :1541'

Confirm that HAProxy is listening:

sudo ss -ltnp 'sport = :1541'

5. Verify DNS and client trust

5.1 Confirm the hostname

On the client, confirm that the name from step 3 resolves to the proxy IP.

Replace the example hostname with the name you chose before running the relevant command below. It should resolve to <PROXY_PUBLIC_IP>. The same hostname must appear in the certificate SAN.

For a DNS record, run:

nslookup db.example.com

For a local hosts-file entry, use the operating system’s resolver. For example, on Linux, run:

getent ahostsv4 db.example.com

5.2 Verify client trust

Your client may already trust the CA that issued your certificate. If it doesn’t, add the CA certificate to the trust store used by your driver. If you created Customer Lab Root CA in section 4.2, supply its public certificate explicitly. Clients do not trust this new CA automatically.

If the administrator workstation is also your client, copy the public CA certificate into the client folder:

mkdir -p ~/adb-proxy-lab/tls
cp ~/adb-proxy-lab-ca/customer-lab-ca.crt ~/adb-proxy-lab/tls/

If you use a separate client machine, transfer customer-lab-ca.crt to that folder on the client. Only the public certificate is needed.

5.3 Set the connection parameters

The place you enter these settings depends on your client. It may be a connection dialog, a connection string, or tnsnames.ora. Independently of the client you use, the settings are:

SettingValue
TransportTCPS
HostYour custom hostname, illustrated as db.example.com
Port1541
ServiceOriginal <ADB_SERVICE_NAME>
Trusted issuerCA chain for the proxy’s server certificate
Server identity validationEnabled against the custom hostname
Database credentialsADB database account credentials

The entry below is for tnsnames.ora. CUSTOM_ADB is the connection alias, you can choose another alias. Replace db.example.com with the hostname chosen in step 3 and <ADB_SERVICE_NAME> with the original service name provided by ADB.

CUSTOM_ADB =
(DESCRIPTION=
  (ADDRESS=(PROTOCOL=TCPS)(HOST=db.example.com)(PORT=1541))
  (CONNECT_DATA=(SERVICE_NAME=<ADB_SERVICE_NAME>))
  (SECURITY=(SSL_SERVER_DN_MATCH=YES))
)

The client now validates the proxy certificate. Keep the original ADB service name.

6. Validate TLS and execute SQL

Let’s check what the client receives before running SQL. In this command, <CLIENT_CA_BUNDLE> is the path to the CA certificates you trust, in PEM format.

If you used the example CA, set <CLIENT_CA_BUNDLE> to ~/adb-proxy-lab/tls/customer-lab-ca.crt. Otherwise, use your issuing CA trust bundle. Replace all three occurrences of db.example.com below with your chosen hostname.

openssl s_client -brief -connect db.example.com:1541 \
  -servername db.example.com -verify_hostname db.example.com \
  -verify_return_error \
  -CAfile <CLIENT_CA_BUNDLE> </dev/null

Our example negotiated TLS 1.3, matched the configured hostname, and reported successful verification.

If that succeeds, try a SQL query through the proxy. Use your custom hostname but keep the original ADB service name. Also check that the client rejects an untrusted certificate and a mismatched hostname.

Conclusion

Your client can now use your hostname and TLS certificate to connect through HAProxy. ADB keeps its Oracle hostname and certificate. HAProxy validates the database certificate, and the client validates the proxy certificate.