CodeIgniter Forums
CI3 | Connect to remote database - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: CI3 | Connect to remote database (/showthread.php?tid=75918)



CI3 | Connect to remote database - janko - 03-29-2020

Hello,
I have a web application with its own MariaDB database. But I also have to connect to another 2 databases that run on clients server (on premise server, normally not connected to internet). 

He told me, there are two ways how I could connect from my app to his server:
1. He enables some port of the server to be accessible from the internet 
2. Connecting to the server via VPN.

Once I will be connected to his server, I access the databases, run some stored procedures and get the result back to my server.
There are two different databases, one is Firebird and the second is MS SQL.

Is this even possible? How would you approach this problem? What way of connecting to the server would you prefer?

Btw, I need a real-time connection. 

Thank you! I will appreciate any suggestions.


RE: CI3 | Connect to remote database - jreklund - 03-29-2020

I would prefer VPN all days of the week, it's the most secure option. Or I would build an API and install it on their servers (on a different server) and make that one public. Not exposing their database server directly to the internet.


RE: CI3 | Connect to remote database - janko - 03-29-2020

(03-29-2020, 06:34 AM)jreklund Wrote: I would prefer VPN all days of the week, it's the most secure option. 
Thank you! VPN makes sense. So lets assume that I will connect via VPN.

I guess I will install VPN on my server and set the settings to connect to their server.
But how do I set my CodeIgniter app? Just add the database specifications in config? 
(I tried to Google "CodeIgniter VPN" but could not find anything relevant.)


RE: CI3 | Connect to remote database - jreklund - 03-29-2020

You just put that servers local IP-adress instead of localhost/127.0.0.1, it's not much too it really. The hard part are setting up the VPN connection itself. Either you install VPN server/client softare on your server or you set up a Site-to-site VPN connection in your firewalls. It depends on your infrastructure.

As you need to connect to a MS Server, you can't use SSH tunnels. And that's a shame.


RE: CI3 | Connect to remote database - janko - 03-30-2020

Good. Many thanks. I will get back to this topic once I do some progress with it and will write here how I solved it.