Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OZ-753: Superset to run behind Nginx proxy #39

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions docker/docker-compose-superset-ports.yaml

This file was deleted.

7 changes: 3 additions & 4 deletions docker/docker-compose-superset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ services:
- ANALYTICS_DB_USER=${ANALYTICS_DB_USER}
- ANALYTICS_DB_HOST=${ANALYTICS_DB_HOST}
- ANALYTICS_DATASOURCE_NAME=${ANALYTICS_DATASOURCE_NAME}
- SUPERSET_PUBLIC_URL=https://${SUPERSET_HOSTNAME}
- KEYCLOAK_URL=https://${KEYCLOAK_HOSTNAME}
- ISSUER_URL=https://${KEYCLOAK_HOSTNAME}/realms/ozone/
- SUPERSET_PUBLIC_URL=${SCHEME}://${SUPERSET_HOSTNAME}
- KEYCLOAK_URL=${SCHEME}://${KEYCLOAK_HOSTNAME}
- ISSUER_URL=${SCHEME}://${KEYCLOAK_HOSTNAME}/realms/ozone/
- SUPERSET_CLIENT_SECRET=${SUPERSET_CLIENT_SECRET}
- SUPERSET_CLIENT_ID=superset
- ENABLE_OAUTH=${ENABLE_OAUTH}
Expand Down Expand Up @@ -93,4 +93,3 @@ networks:
ozone-analytics:
web:
external: true
name: web
23 changes: 23 additions & 0 deletions docker/proxy/docker-compose-nginx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
services:
proxy:
image: nginx:1.25-alpine
healthcheck:
test: ["CMD", "curl", "-f", "http://proxy:80"]
networks:
- ozone-analytics
- web
ports:
- "8088:8088"
restart: unless-stopped
volumes:
- "${PROXY_TLS_CERTS_PATH:-proxy-tls-certs}:/etc/tls"
- ./nginx.conf:/etc/nginx/nginx.conf
- ./superset.nginx.conf:/etc/nginx/conf.d/superset.nginx.conf

networks:
ozone-analytics:
web:
external: true

volumes:
proxy-tls-certs: ~
31 changes: 31 additions & 0 deletions docker/proxy/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
user nobody;
worker_processes auto;

error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
tcp_nopush on;
tcp_nodelay on;

keepalive_timeout 65;
resolver 127.0.0.11;

include /etc/nginx/conf.d/*.conf;
}
9 changes: 9 additions & 0 deletions docker/proxy/superset.nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
server {
listen 8088;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
set $superset superset:8088;
proxy_pass http://$superset;
}
}
2 changes: 1 addition & 1 deletion scripts/destroy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ setTraefikIP

setTraefikHostnames

docker compose -p ozone-analytics -f ../docker/docker-compose-db.yaml -f ../docker/docker-compose-migration.yaml -f ../docker/docker-compose-streaming-common.yaml -f ../docker/docker-compose-kowl.yaml -f ../docker/docker-compose-superset.yaml down -v
docker compose -p ozone-analytics down -v
35 changes: 31 additions & 4 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,37 @@ setDockerHost
# Export the paths variables to point to distro artifacts
exportEnvs

setTraefikIP

setTraefikHostnames
# Export IP address of the host machine
if [ "$ENABLE_OAUTH" == "true" ]; then
exportHostIP
fi

# Set the Traefik host names
if [ "$TRAEFIK" == "true" ]; then
echo "$INFO \$TRAEFIK=true, setting Traefik hostnames..."
setTraefikIP
setTraefikHostnames
else
echo "$INFO \$TRAEFIK!=true, setting Nginx hostnames..."
setNginxHostnames
fi

echo "$CONNECT_ODOO_DB_NAME"

docker compose -p ozone-analytics -f ../docker/docker-compose-db.yaml -f ../docker/docker-compose-migration.yaml -f ../docker/docker-compose-streaming-common.yaml -f ../docker/docker-compose-kowl.yaml -f ../docker/docker-compose-superset.yaml -f ../docker/docker-compose-superset-ports.yaml up -d
# Run Ozone Analytics Services
dockerComposeCommand="docker compose -p ozone-analytics -f ../docker/docker-compose-db.yaml -f ../docker/docker-compose-migration.yaml -f ../docker/docker-compose-streaming-common.yaml -f ../docker/docker-compose-kowl.yaml -f ../docker/docker-compose-superset.yaml up -d"
echo "$INFO Running Ozone Analytics Services..."
echo "$dockerComposeCommand"
$dockerComposeCommand

# Run the Nginx Proxy service, if $TRAEFIK!=true
if [ "$TRAEFIK" != "true" ]; then
dockerComposeProxyCommand="docker compose -p ozone-analytics -f ../docker/proxy/docker-compose-nginx.yaml up -d"
echo "$INFO Running Nginx proxy service (\$TRAEFIK!=true)..."
echo ""
echo "$dockerComposeProxyCommand"
echo ""
($dockerComposeProxyCommand)
else
echo "$INFO Skipping running Nginx proxy... (\$TRAEFIK=true)"
fi
28 changes: 28 additions & 0 deletions scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function exportEnvs () {
export SUPERSET_CONFIG_PATH=../docker/superset/config
export SUPERSET_DASHBOARDS_PATH=$DISTRO_PATH/configs/superset/assets/
export JAVA_OPTS='-Xms2048m -Xmx8192m';
export SCHEME=https

echo "→ ANALYTICS_CONFIG_FILE_PATH=$ANALYTICS_CONFIG_FILE_PATH"
echo "→ ANALYTICS_DB_PORT=$ANALYTICS_DB_PORT"
Expand Down Expand Up @@ -116,11 +117,38 @@ function setTraefikIP {
fi
}

function exportHostIP() {
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux
export HOST_IP_ADDRESS=$(hostname -I | awk '{print $1}')
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
export HOST_IP_ADDRESS=$(ipconfig getifaddr en0)
else
echo "$ERROR Unsupported OS type: $OSTYPE"
return 1
fi
echo "$INFO IP address set to: $HOST_IP_ADDRESS"
}

function setTraefikHostnames {
echo "$INFO Exporting Traefik hostnames..."

export SUPERSET_HOSTNAME=analytics-"${IP_WITH_DASHES}.traefik.me"
export KEYCLOAK_HOSTNAME=auth-"${IP_WITH_DASHES}.traefik.me"

echo "→ SUPERSET_HOSTNAME=$SUPERSET_HOSTNAME"
echo "→ KEYCLOAK_HOSTNAME=$KEYCLOAK_HOSTNAME"
}

function setNginxHostnames() {
echo "$INFO Exporting Nginx hostnames..."

export SUPERSET_HOSTNAME="${HOST_IP_ADDRESS:-localhost}:8088"
export KEYCLOAK_HOSTNAME="${HOST_IP_ADDRESS:-localhost}:8084"
export SCHEME=http

echo "→ SUPERSET_HOSTNAME=$SUPERSET_HOSTNAME"
echo "→ KEYCLOAK_HOSTNAME=$KEYCLOAK_HOSTNAME"
echo "→ SCHEME=$SCHEME"
}
Loading