Last updated

Set up a custom domain name

There are two ways to setup your server for a custom domain name for forms: using Apache HTTP Server or Nginx.

Apache HTTP Server

Prerequisites
  • Debian or Ubuntu operating systems
  • Apache HTTP Server version 2.4.59
  1. Install the apache2 package:
sudo apt update
sudo apt install apache2
  1. Enable required Apache modules:
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_balancer
sudo a2enmod lbmethod_byrequests
  1. Obtain a valid SSL certificate (e.g., Let’s Encrypt).

  2. Use the following example configuration, modifying kyc.example.com to match your domain and certificate details:

forms-reverse-proxy-apache.conf
<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    ServerName kyc.example.com
    DocumentRoot /var/www/kyc.example.com

    SSLEngine On
    SSLProxyEngine On
    SSLProxyVerify none
    SSLProxyCheckPeerCN off
    SSLProxyCheckPeerName off

    ProxyRequests Off
    ProxyPreserveHost On
    ProxyPass / https://forms.kycaid.com/
    ProxyPassReverse / https://forms.kycaid.com/

    ErrorLog ${APACHE_LOG_DIR}/reverseproxy_error.log
    CustomLog ${APACHE_LOG_DIR}/reverseproxy_access.log combined

    SSLCertificateFile /etc/letsencrypt/live/kyc.example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/kyc.example.com/privkey.pem
</VirtualHost>

Nginx

Prerequisites
  • Debian or Ubuntu operating systems
  • Nginx version 1.22.1
  1. Install the nginx package:
sudo apt update
sudo apt install nginx
  1. Obtain a valid SSL certificate (e.g. Let’s Encrypt).

  2. Use the following example configuration, modifying kyc.example.com to match your domain and certificate details:

forms-reverse-proxy-nginx.conf
# Reverse proxy for kyc.example.com
server {
    server_name kyc.example.com;
    root /var/www/kyc.example.com;
    index index.html;

    # Reverse proxy settings
    location / {
        proxy_pass https://forms.kycaid.com;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    listen [::]:443 ssl ipv6only=on;
    listen 443 ssl;

    ssl_certificate /etc/letsencrypt/live/kyc.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/kyc.example.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}

# Redirect HTTP to HTTPS
server {
    if ($host = kyc.example.com) {
        return 301 https://$host$request_uri;
    }

    listen 80;
    listen [::]:80;
    server_name kyc.example.com;
    return 404;
}