Skip to content

DHIS2 Superset Gateway installation

This guide covers the installation of the DHIS2 Superset Gateway service. The DHIS2 Superset Gateway is a backend service and API for connecting DHIS2 and Apache Superset.

The gateway provides access control for DHIS2 external dashboards and access and guest tokens for embedded dashboards in Superset. External dashboards are stored in the DHIS2 data store using the DHIS2 data store API.

The service key is dhis2-superset-gateway. The service port is 8092.

This guide assumes that a dedicated user for running the service called bao-admin exists.

JAR file

The service is available as an executable JAR file. The filename is dhis2-superset-gateway.jar.

The JAR file should be installed in the following location.

/var/lib/dhis2-superset-gateway/dhis2-superset-gateway.jar

Create the directory manually and make bao-admin the owner.

sudo mkdir /var/lib/dhis2-superset-gateway
sudo chown bao-admin:bao-admin /var/lib/dhis2-superset-gateway

Place the JAR file in the previously created directory and make bao-admin the owner.

sudo cp dhis2-superset-gateway.jar /var/lib/dhis2-superset-gateway
sudo chown bao-admin:bao-admin /var/lib/dhis2-superset-gateway/dhis2-superset-gateway.jar

Systemd

The systemd service manager is used to manage the service process.

The systemd service file should be located in the /etc/systemd/system directory.

/etc/systemd/system/dhis2-superset-gateway.service

Create the system service file with the following content.

sudo nano /etc/systemd/system/dhis2-superset-gateway.service
[Unit]
Description = DHIS2 Superset Gateway service

[Service]
Environment="JAVA_OPTS=-Xms512M -Xmx1024M"
ExecStart = /var/lib/dhis2-superset-gateway/dhis2-superset-gateway.jar
User = bao-admin

[Install]
WantedBy = multi-user.target

To enable the services on boot, invoke the following command.

sudo systemctl enable dhis2-superset-gateway

Configuration

The service is configured with a properties file called dhis2-superset-gateway.properties.

The file should reside in the following location.

/opt/dhis2-superset-gateway/dhis2-superset-gateway.properties

Create a configuration file with the following content.

sudo mkdir /opt/dhis2-superset-gateway
sudo nano /opt/dhis2-superset-gateway/dhis2-superset-gateway.properties
# ----------------------------------------------------------
# DHIS2
# ----------------------------------------------------------

# Base URL to DHIS2
dhis2.base_url = https://dhis2.mydomain.org

# ----------------------------------------------------------
# Apache Superset
# ----------------------------------------------------------

# Base URL to Superset
superset.base_url = https://superset.mydomain.org

# Username for Superset user account
superset.username = myusername

# Password for Superset user account (confidential)
superset.password = xxxx

# ----------------------------------------------------------
# CORS
# ----------------------------------------------------------

# Origins from which to allow CORS
cors.allowed_origins = http://localhost:3000,\
                       http://localhost:9000,

Proxy

The service provides API endpoints. To make the API endpoints accessible, an HTTP proxy must be set up.

This is typically done by specifying a location block in nginx. In the nginx configuration file for DHIS2, immediately before the location block for DHIS2 itself, specify a location block for the DHIS2 Superset Gateway service.

server {
  # ..
  # DHIS2 Superset gateway
  location /superset-gateway/ {
    proxy_pass         http://127.0.0.1:8092/superset-gateway/;
    proxy_set_header   Host                $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;
    proxy_set_header   X-Forwarded-Port    $server_port;
  }
}

Logging

The service uses the journalctl tool to view logs. To view log output, invoke the following command.

sudo journalctl -n 500 -f -u dhis2-superset-gateway

Start

The service is started by invoking the following command.

sudo systemctl start dhis2-superset-gateway

Stop

The service is stopped by invoking the following command.

sudo systemctl stop dhis2-superset-gateway