Whitelisting ips to a website database

Connect with other users about what to run on your webhosting (and how to run it) here.
Post Reply
SpY998
New to forums
New to forums
Posts: 1
https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
Joined: Thu Mar 05, 2015 12:35 pm

Whitelisting ips to a website database

Post by SpY998 »

I'm wondering if it's possible to whitelist ips to only allow their connection to a database, is it possible?
QuickQAnonymous
A regular
A regular
Posts: 44
Joined: Thu Feb 19, 2015 6:50 am

Re: Whitelisting ips to a website database

Post by QuickQAnonymous »

Well, firstly, remember that IPs change by default. So all the IPs will either have to be static or else you will have to frequently update scripts or whatever.

Now then, you could use PHP. It has a couple tools (e.g. $_SERVER) for getting the ip, and when connecting, make sure with an if that the ip matches one of the ips before connecting. Or consider htaccess, although if it is just a page or two that you want protected,... then maybe not that way. If you also want to restrict phpMyAdmin access, if you are not on NFOServers and this may apply to other servers, remember first that it is password protected. If you still wish to continue, you could add a htaccess to the phpMyAdmin folder.

I hope this helps!


PHP Website, although it already installed on NFO servers and many others
Handy .htaccess reference. htaccess comes with Apache servers, which all NFO servers are currently, I think.
User avatar
soja
This is my homepage
This is my homepage
Posts: 2389
Joined: Fri May 18, 2012 3:20 pm

Re: Whitelisting ips to a website database

Post by soja »

On NFO's web hosting it isn't possible to make a whitelist of IPs that can access your database, you either allow all remote IPs or none.

If you are using your own database server, the most common practice I have seen is to make a new user for every IP address you wish to allow.

For example:
Allow user1@host1
Allow user1@host2

What database software are you using, and who is the host? I can help better if I know these details.
Not a NFO employee
Jake
A regular
A regular
Posts: 52
Joined: Wed May 28, 2014 9:20 pm

Re: Whitelisting ips to a website database

Post by Jake »

I'm using the NFoservers webhosting and I'd like this feature too. It seems like something good to add for security measures, just to block the mysql port to all except for a whitelist of IPs (whitelist localhost and maybe a few gameservers, block everything else)
User avatar
soja
This is my homepage
This is my homepage
Posts: 2389
Joined: Fri May 18, 2012 3:20 pm

Re: Whitelisting ips to a website database

Post by soja »

Jake wrote:I'm using the NFoservers webhosting and I'd like this feature too. It seems like something good to add for security measures, just to block the mysql port to all except for a whitelist of IPs (whitelist localhost and maybe a few gameservers, block everything else)
The MySQL server on web hosting serves all clients. Blocking access using a firewall as you suggested wouldn't make sense.

The traditional way of whitelisting IPs is using mysql users, which NFO doesn't currently support. You could do this on your own MySQL installation though if you'd like.
Not a NFO employee
Post Reply