Below is a snippet of nginx configuration that will enable access to your UniFi Controller (eg. Unifi Cloud Key Gen2) using nginx reverse proxy.
server {
listen 443 ssl;
server_name example.com;
location / {
include /etc/nginx/proxy_params;
proxy_pass https://IP_ADDRESS_OF_THE_CONTROLLER/;
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}