From 4fd1cde2f12f9f4d5b3d2edca93f660beddb184f Mon Sep 17 00:00:00 2001 From: Henry Barreto Date: Tue, 10 Dec 2024 14:14:39 -0300 Subject: [PATCH] feat(gateway): add env variable to control tunnels domain --- .env | 4 ++++ docker-compose.yml | 1 + gateway/config.go | 1 + gateway/nginx/conf.d/shellhub.conf | 2 +- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.env b/.env index 9920b614fb7..5b2076f137d 100644 --- a/.env +++ b/.env @@ -43,8 +43,12 @@ SHELLHUB_DOMAIN=localhost # VALUES: A valid network name SHELLHUB_NETWORK=shellhub_network +# Enable tunnels feature. SHELLHUB_TUNNELS=false +# The domain used to create the tunnels. If empty, the [SHELLHUB_DOMAIN] will be used. +SHELLHUB_TUNNELS_DOMAIN= + # Specifies an alternative mirror URL for downloading the GeoIP databases. This # field takes precedence over SHELLHUB_MAXMIND_LICENSE; when both are # configured, SHELLHUB_MAXMIND_MIRROR will be used as the primary source for diff --git a/docker-compose.yml b/docker-compose.yml index 26b27e8283f..45ee86e17e8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -93,6 +93,7 @@ services: environment: - SHELLHUB_DOMAIN=${SHELLHUB_DOMAIN} - SHELLHUB_TUNNELS=${SHELLHUB_TUNNELS} + - SHELLHUB_TUNNELS_DOMAIN=${SHELLHUB_TUNNELS_DOMAIN} - SHELLHUB_VERSION=${SHELLHUB_VERSION} - SHELLHUB_SSH_PORT=${SHELLHUB_SSH_PORT} - SHELLHUB_PROXY=${SHELLHUB_PROXY} diff --git a/gateway/config.go b/gateway/config.go index 6d947672f69..db8cd081214 100644 --- a/gateway/config.go +++ b/gateway/config.go @@ -14,6 +14,7 @@ type GatewayConfig struct { Env string `env:"SHELLHUB_ENV"` Domain string `env:"SHELLHUB_DOMAIN,required" validate:"hostname"` Tunnels bool `env:"SHELLHUB_TUNNELS,default=false"` + TunnelsDomain string `env:"SHELLHUB_TUNNELS_DOMAIN"` WorkerProcesses string `env:"WORKER_PROCESSES,default=auto"` MaxWorkerOpenFiles int `env:"MAX_WORKER_OPEN_FILES,default=0"` MaxWorkerConnections int `env:"MAX_WORKER_CONNECTIONS,default=16384"` diff --git a/gateway/nginx/conf.d/shellhub.conf b/gateway/nginx/conf.d/shellhub.conf index 7dfc353050e..695ad946e22 100644 --- a/gateway/nginx/conf.d/shellhub.conf +++ b/gateway/nginx/conf.d/shellhub.conf @@ -643,7 +643,7 @@ server { } {{ if and $cfg.EnableEnterprise $cfg.Tunnels -}} -{{ $DOMAIN := $cfg.Domain }} +{{ $DOMAIN := or $cfg.TunnelsDomain $cfg.Domain }} server { {{ if and ($cfg.EnableAutoSSL) (ne $cfg.Env "development") -}} listen 443;