QGTunnel Heroku MariaDB Database Connection Setup Guide

    Table of contents

    To setup QGTunnel for QuotaGuard via Heroku for MariaDB database connections, we suggest you go with the SOCKS proxy using our QGTunnel software. Here are some setup instruction to get you started:

    Step 1. Download QGTunnel and Save to Root of Your Project

    curl https://s3.amazonaws.com/quotaguard/qgtunnel-latest.tar.gz | tar xz

    Step 2. Log in to QuotaGuard Dashboard and Create the Tunnel

    Using the Heroku CLI you can log into our dashboard with the following command:

    heroku addons:open quotaguardstatic

    Or if you prefer, you can login from the Heroku dashboard by clicking on QuotaGuard Static on the resources tab of your application.

    Once you are logged into our dashboard, in the top right menu, go to Setup (Gear Icon), click on QGTunnel Configuration, then “Create a Tunnel”.

    Fill in the following data:

    Remote Destination: tcp://hostname.for.your.server.com:3306
    Local Port: 3306
    Transparent: true
    Encrypted: false
    

    This setup assumes that the remote MariaDB server is located at hostname.for.your.server.com and is listening on port 3306. This is usually the default port.

    The Local Port is the port number that QGTunnel will listen on. In this example we set it to 3306, but if you have another process using 3306, you may have to change it (ie: 3307).

    Transparent mode allows QGTunnel to override the DNS for hostname.for.your.server.com to 127.0.0.1, which redirects traffic to the QGTunnel software. This means you can connect to either hostname.for.your.server.com or 127.0.0.1 to connect through the tunnel.

    Encrypted mode can be used to encrypt data end-to-end, but if your protocol is already encrypted then you don’t need to spend time setting it up. We believe MariaDB is already encrypted, but you should always double check.

    Step 3: Change Your Code to Connect Through the Tunnel

    With transparent mode and matching Local and Remote ports you should not need to change your code. You can also connect to 127.0.0.1:3306.

    Without transparent mode, you will want to connect to 127.0.0.1:3306.

    Step 4: Change your Startup Code:

    Change the startup code that starts up your application. In Heroku this is done with a Procfile. Basically you just need to prepend your startup code with “bin/qgtunnel”.

    So for a Procfile that was previously:

    web: your-application your arguments

    you would now want:

    web: bin/qgtunnel your-application your arguments

    If you do not have a Procfile, then heroku is using a default setup in place of the Procfile based on the framework or language you are using. You can usually find this information on the Overview tab of the application in Heroku’s dashboard. It is usually under the heading “Dyno Information”.

    Step 5: Commit and Push your Code

    Be sure that the file bin/qgtunnel is added to your repository.

    If you are using transparent mode, be sure that vendor/nss_wrapper/libnss_wrapper.so is also added to your repository.

    If you are not using transparent mode, you will want to set the environment variable QGTUNNEL_DNSMODE to DISABLED to avoid seeing an error message in your logs.

    Step 6: Troubleshoot Any Problems

    If you have problems, enable the environment variable QGTUNNEL_DEBUG=true and then restart your application while watching the logs.

    If you can’t figure it out, send QuotaGuard Support the information in the logs. Please redact any sensitive information, including your QuotaGuard connection URL because it contains your password.

    Step 7: VERY IMPORTANT

    After you get everything working, we suggest you download your QGTunnel configuration from our dashboard as a .qgtunnel file and put that in the root of your project. This prevents your project from relying on the QuotaGuard website during startup.

    Alternatively you can put the contents of the downloaded configuration file in a QGTUNNEL_CONFIG environment variable.

    By following these steps, you can set up QGTunnel for Heroku MariaDB database connections using QuotaGuard’s Static IP services. If you have any questions or issues, contact QuotaGuard Support for assistance.


    Ready to Get Started?

    Get in touch or create a free trial account