Forum Moderators: phranque
Background:
I have a web host in the US running Apache that contains my website. We have a company in Japan that runs a database server for our Japanese site. We would like to use the database server in Japan to power the website hosted in the US as well.
Quandary:
I was told that it should be possible to configure Apache (the server in the US) to use the server in Japan as some sort of virtual host. Essentially we want the site to remain hosted in the US, but to be able to pull data from the Japan database.
First, I'd like to know if this is possible. If so, what would I need on the Apache server?
Second, are there security implications in doing this? This is not an e-commerce site. It's essentially a big product catalog. No sensitive data would be passed along. Will I run into problems with hosting companies allowing me to do this even with a dedicated server?
I really need some prodding in the right direction so that I can ask my host the right questions and see whether this scheme is feasible.
All you need to do is set the username you use to be able to access with a wildcard (%) symbol. That works on my server anyway as I use my home machine as a testing server and run database queries from the server to it.
Sounds similar to what you need to do... You may need to login as root to change the value however on my server you can just add it in the MySql control panel (Not phpMyAdmin)...
My server uses CPanel, if yours has it then I can tell you how to do it...
Im playing with postGre at the moment to see if you can setup remote access, will tell you in a bit (when its finished installing)...
as Angelis mentioned, it's just a db, the site is actually on the US server
I see a couple of options
1. connect remotely to the db in japan
strictly looking from a php perspective as I have no idea what you are using on the US site
from
[php.net...]
The connection_string can be empty to use all default parameters, or it can contain one or more parameter settings separated by whitespace. Each parameter setting is in the form keyword = value. Spaces around the equal sign are optional. To write an empty value or a value containing spaces, surround it with single quotes, e.g., keyword = 'a value'. Single quotes and backslashes within the value must be escaped with a backslash, i.e., \' and \\.The currently recognized parameter keywords are: host, hostaddr, port, dbname, user, password, connect_timeout, options, tty (ignored), sslmode, requiressl (deprecated in favor of sslmode), and service. Which of these arguments exist depends on your PostgreSQL version.
essentially you can call this postgresql connection function and give it all the host data to have it connect wherever. Shouldn't really matter where the db is physically located, localhost is just a host address like any other.
2. keep the db in japan and export it into a local db on the US server
I don't see why you can't do this, have a cron or scheduled task that grabs the data from japan server and brings it over and dumps it in the local db. There are 2 sides to this so you could have the japan server send it over on a schedule and the us server grab that file and dump it into the db.
whatever but it would maybe be a better option as remote db servers sometimes make things a little slow. You would have to figure out a schedule that made sense for keeping the site up to date and also not having it take too long. Could be every hour/day/week or or every 15 mins if you really wanted but that could be a little too short.
If you ever needed to make an immediate change you just connect straight to the US server to make the change, making sure you have already made the change on the JP server so the next update doesn't get messed up.
If they can set up postgresql on the local this might be a pretty easy fix.
there are some examples on that page for the remote connect
$conn_string = "host=sheep port=5432 dbname=test user=lamb password=bar";
$dbconn4 = pg_connect($conn_string);
//connect to a database named "test" on the host "sheep" with a username and password
There were permission problems with the Japanese hosting company. They complained that using pg_connect in this way would open them to security concerns. That plan fell through.
Next we were looking at the mod_proxy module in Apache. That looked promising for a bit, but there were speed and testing concerns. We finally settled on rebuilding the entire system on the US server, PostgreSQL database and all...which I'd been telling them all along would be the best option.