Nginx Installation
Step 1: Install Nginx
sudo apt-get install nginxStep 2: Check Status
sudo systemctl status nginxInstall Java
sudo apt install default-jreCheck Java Version
java -versionOutput:
openjdk version "17.0.10" 2024-01-16
OpenJDK Runtime Environment (build 17.0.10+7-Ubuntu-123.10.1)
OpenJDK 64-Bit Server VM (build 17.0.10+7-Ubuntu-123.10.1, mixed mode, sharing)Metabase Installation and Configuration
Step 1: Update packages:
sudo apt update -y && sudo apt upgrade -yStep 2: Download Metabase
Make sure to move this file to /var/www/html/metabase
wget https://downloads.metabase.com/v0.48.8/metabase.jarStep 3: Create user & group
sudo groupadd -r metabase
sudo useradd -r -s /bin/false -g metabase metabaseStep 4: Create folder and set permissions
sudo mkdir /var/www/html/metabase
sudo chown -R metabase:metabase /var/www/html/metabaseStep 5: Create log file and set permissions
sudo touch /var/log/metabase.log
sudo chown syslog:adm /var/log/metabase.logStep 6: Create metabase configuration file and set permissions
sudo touch /etc/default/metabase
sudo chmod 640 /etc/default/metabaseStep 7: Create a Metabase Service
sudo touch /etc/systemd/system/metabase.service
sudo vi /etc/systemd/system/metabase.serviceCopy and Paste below content in metabase.service
[Unit]
Description=Metabase server
After=syslog.target
After=network.target
[Service]
WorkingDirectory=/var/www/html/metabase
ExecStart=/usr/bin/java -jar /var/www/html/metabase/metabase.jar
EnvironmentFile=/etc/default/metabase
User=metabase
Type=simple
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=metabase
SuccessExitStatus=143
TimeoutStopSec=120
Restart=always
[Install]
WantedBy=multi-user.targetStep 8: Create Syslog Config
sudo touch /etc/rsyslog.d/metabase.conf
sudo vi /etc/rsyslog.d/metabase.confAdd following code in metabase.conf
if $programname == 'metabase' then /var/log/metabase.log
& stopRestart the syslog service to apply new changes
sudo systemctl restart rsyslog.serviceStep 9: Create environment variables
sudo vi /etc/default/metabaseAdd the following content and save
NOTE: This tutorial assumes you have PostgreSQL setup. Below configurations are required for Metabase to create its own tables and configuration in PostgreSQL DB.
MB_PASSWORD_COMPLEXITY=strong
MB_PASSWORD_LENGTH=10
#MB_JETTY_HOST=<0.0.0.0>
#MB_JETTY_PORT=<12345>
MB_DB_TYPE=postgres
MB_DB_DBNAME=<your_metabase_db_name>
MB_DB_PORT=<5432>
MB_DB_USER=<your_metabase_db_user>
MB_DB_PASS=<ssshhhh>
MB_DB_HOST=<localhost>
MB_EMOJI_IN_LOGS=false
# any other env vars you want available to MetabaseStep 10: Move Metabase jar file
sudo mv ~/metabase.jar /var/www/html/metabase
sudo chown -R metabase:metabase metabase.jarNginx configuration
Create nginx conf for metabase
sudo vi /etc/nginx/sites-available/metabaseCopy and paste below content and save the file
server {
listen 80;
listen [::]:80;
server_name your.domain.com;
location / {
proxy_pass http://127.0.0.1:3000;
}
}Create a symbolic link
sudo ln -s /etc/nginx/sites-available/metabase /etc/nginx/sites-enabled/Check for configuration
sudo nginx -tReload Nginx configuration
sudo systemctl reload nginxRestart Metabase Service
sudo systemctl daemon-reload
sudo systemctl start metabase.service
sudo systemctl status metabase.serviceEnable Metabase service on reboot
sudo systemctl enable metabase.serviceThats it! you have successfully configured metabase with nginx on Ubuntu server.
Next, I would recommend configuring LetsEncrypt SSL to secure Metabase over secure HTTPS connection. Follow this guide on how to setup SSL for Metabase.