- Setup Custom Local Domain Name
- Linux and MacOS
- Windows
- Setup Metabase and HTTPS
- Generate Java Keystore
- Run Metabase with Environment Variables
- Setup Metabase Pro/Enterprise Version
- Enable Interactive Embedding
- Setup SSO
- Enable SSO with JWT
- Setup Embedding App
- Set environment variables
- Running the Embedded App
1-setup-custom-domain.mp4
In order for cross-site embedding to work locally, we have to setup our localhost under a custom domain.
On Linux and MacOS, you can edit the file /etc/hosts
adding an entry with your custom domain name.
sudo nano /etc/hosts
You should already see an entry like
127.0.0.1 localhost
in /etc/hosts
.
We want to add an additional entry, so we can serve Metabase under localhost and our embedding app under a different domain.
Add an entry to /etc/hosts
and make sure the second to last digit is different from your localhost. i.e. 127.0.0.1 localhost
has a different localhost ip then 127.0.1.1
.
127.0.1.1 embedding.local
Now when you run apps locally, you have two links you can access them through: http://localhost
and http://embedding.local
and they will be recognized as different sites by your browser.
Note: You may need to flush your DNS cache for these changes to take effect immediately. Test the changes first and if it does not work immediately, check your local system requirements for how to flush your DNS cache.
Not tested on Windows but works in the same vain. /etc/hosts
should be under \Windows\System32\drivers\etc\hosts
instead.
2a-setup-metabase-https.mp4
- Get the keytool tool (should be already installed with Java 11+)
- Generate the keystore to store the cerficate files
keytool -genkey -keyalg RSA -alias localhost -keystore selfsigned.jks -validity 365 -keysize 2048
when asked about password use storepass
and when asked about several inputs, always use localhost
when it says
Is CN=localhost, OU=localhost, O=localhost, L=localhost, ST=localhost, C=localhost correct?
you should enter "yes"
- when you finish creating the keystore, try checking if everything is cool with the following:
keytool -list -keystore selfsigned.jks
you should see something similar to
Keystore type: PKCS12
Keystore provider: SUN
Your keystore contains 1 entry
localhost, Apr 4, 2023, PrivateKeyEntry,
Certificate fingerprint (SHA-256): xx:xx:xx:xx:...
In your Metabase app directory, start the developer instance with these SSL variables exported.
export MB_JETTY_SSL=true
export MB_JETTY_SSL_PORT=8443
export MB_JETTY_SSL_KEYSTORE=[/path/to/keystore.jks]
export MB_JETTY_SSL_KEYSTORE_PASSWORD=storepass
yarn dev-ee
Metabase should now be available at https://localhost:8443.
You'll need a Pro or Enterprise version of Metabase up and running use JWT SSO.
- Setup Metabase as Pro/Enterprise Version
- Add you license token in admin settings > license & billing
2b-setup-interactive-embedding.mp4
- Go to Admin Settings > Embedding
- Click Enable
- Go to Admin Settings > Embedding > Interactive Embedding
- For your embedding app, add to authorized origins:
http://embedding.local:8081
- (if using SSO) Set SameSite cookie to
none
3-setup-SSO.mp4
Go to Admin Settings > Settings > Authentication.
On the card that says JWT, click the Setup button.
In JWT IDENTITY PROVIDER URI field, paste http://embedding.local:8081/login
.
Click the Generate key button. Copy the key.
4-setup-embed-app.mp4
You'll need to set some environment variables for your server.
export METABASE_SITE_URL="https://myapp.metabaseapp.com"
Replacing https://myapp.metabaseapp.com
with the root path of your Metabase. In the local case, https://localhost:8443
export METABASE_JWT_SHARED_SECRET="COPY_SECRET_FROM_JWT_CONFIG"
You can get this key from your Metabase by clicking on the gear icon and going to Admin Settings > Settings > Authentication > JWT.
Find the dashboard you want to redirect to on initial login and its id. Then export the variable below replacing id
with the ID number of your dashboard.
export METABASE_DASHBOARD_PATH="/dashboard/id"
If you have a specific user you know you want to test in the embed, you can add that user's email to the JWT SSO and sign-in with that user's email.
export SSO_CONNECTED_EMAIL="[email protected]"
Start the server by running:
yarn dev
The app runs by default on port 8081.
Visit http://embedding.local:8081/analytics
and sign in with your exported email and password as "password", or with the pre-defined user below
user: [email protected]
password: password