Report this

What is the reason for this report?

How do I set up SSH tunnel from inside docker image droplet to access another droplet's MySQL Database?

Posted on March 25, 2024

I have a droplet with a docker image hosting Appsmith - a low-code development platform. I want to set up an Appsmith datasource to a MySQL instance on another droplet that is not in the client droplet’s network. I’m not real good at Linux so I definitely need some guidance. I can connect to the server via SSH tunnel from my laptop.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Heya,

You should be able to do that using a similar approach as to how you would go about when trying to configure access to another MySQL Droplet even when it’s not being inside a docker container.

By default, MySQL is configured to listen for connections only from the local machine. You need to change this so that it can accept connections from your Appsmith droplet.

Also if you do not have a user, create one. Create a user (or use an existing one) and grant privileges. Replace appsmith_user, password, and appsmith_droplet_ip with appropriate values:

CREATE USER 'appsmith_user'@'appsmith_droplet_ip' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'appsmith_user'@'appsmith_droplet_ip'; FLUSH PRIVILEGES;

If either of your droplets has a firewall enabled, you’ll need to configure it to allow the necessary traffic:

  1. MySQL Server Droplet:

    • Allow incoming connections on port 3306 (MySQL’s default port) from the Appsmith droplet’s IP address.

    • Using ufw (Uncomplicated Firewall) as an example:

      bashCopy code sudo ufw allow from appsmith_droplet_ip to any port 3306

  2. Appsmith Droplet:

    • Usually, outgoing connections are allowed, but if you have set up strict outbound rules, ensure that the droplet can make outbound requests to the MySQL server droplet on port 3306.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.