Enabling HTTPS
Configure DNS
If you already have a certificate and key you can skip this.
For example point gamebench.example.com to the server.
Firewall
If you already have a certificate and key you can skip this.
Ensure both ports 80 and 443 are accessible from the internet. This is only necessary if you plan to use the Let’s Encrypt standalone example below.
If your server is behind a firewall or VPN, as we recommend, use DNS validation instead. These ports do not need to be opened for it.
Issue a certificate
If you already have a certificate and key you can skip this.
Example using Let’s Encrypt:
- Install
certbotsee https://certbot.eff.org/docs/install.html - Stop frontend container if running (
docker stop frontend) - Run
sudo certbot certonly --standalone -d gamebench.example.comreplacing gamebench.example.com with your domain.
Servers behind a firewall or VPN
Let’s Encrypt cannot reach a server that is not accessible from the internet, so the standalone example above will not work. Use DNS validation instead, which proves ownership of your domain through a DNS record. Your domain must be in public DNS, but it can point to a private IP address.
We recommend using the certbot DNS plugin for your DNS provider, as this allows certificates to renew automatically. Follow the plugin’s documentation to issue the certificate, then continue with the steps below.
We recommend a publicly trusted certificate over one issued by a private certificate authority. Android 7 and later apps do not trust user-installed certificate authorities by default, so apps using the GameBench SDK may be unable to upload sessions to a server using a private certificate.
Reconfigure
cd /path/to/gamebench
mkdir certs
# Set permissions so nginx user can read the files
chown -R 1001:1001 certsCopy certificate and key into newly created certs directory.
For example:
sudo cp /etc/letsencrypt/live/gamebench.example.com/fullchain.pem certs/cert.pem
sudo cp /etc/letsencrypt/live/gamebench.example.com/privkey.pem certs/key.pemRun ./gbctl
Double-check the values for the frontend host and port. The host should be the domain name i.e. gamebench.example.com and the port should be 443.
Frontend host
Host frontend is accessible on.
(Default: )
Frontend port
Port published to host for the frontend container. Only published if publish ports to host option is chosen.
(Default: )Enter yes for
TLS enabled
Whether URLs should use https protocol
(Default: no)Enter yes for
Enable TLS in Nginx configuration?
If you wish to terminate TLS on the server, use this option.
In the current directory, create a new directory called `certs` and add the private key (`key.pem`) and cert (`cert.pem`.)
The `cert.pem` should contain any intermediate certificates.
(Default: no)Certificate renewal
Example certificate renewal command when using certbot. Replace /path/to/gamebench with your path to the gamebench deployment.
sudo certbot renew --pre-hook "docker stop frontend" --post-hook "docker start frontend" --deploy-hook "cp \$RENEWED_LINEAGE/fullchain.pem /path/to/gamebench/certs/cert.pem; cp \$RENEWED_LINEAGE/privkey.pem /path/to/gamebench/certs/key.pem; docker restart frontend"This should be run twice daily. Please note on Ubuntu 18.04 with the certbot package you will want to replace or remove the provided systemd certbot timer as it won’t be configured with the appropriate pre, post and deploy hooks.
If you issued your certificate using DNS validation, the frontend container does not need to be stopped during renewal, so you can leave out --pre-hook and --post-hook. Keep the --deploy-hook, which copies the renewed certificate and restarts the container.