1

Topic: Connection to PgSQL and data acquisition

Good afternoon, is available:
1. Server Ubuntu14+apach2+PhP5+OpenVpNserver
2. Server Windows+PgSQL+VPNClient
Servers are connected by means of OpenVPN
Ubuntu=10.8.0.1+1.2.3.4 (Exterior for an example)
Windows=10.8.0.3
In PHP it is necessary to fulfill request to PgSQL to the server and to receive the answer.
At first tried to make through pg_connect but it turned out nothing, after installed PDO and the driver pgsql, to be connected again it is not possible.
[spoiler]

try {
$db = new PDO ("pgsql:host=10.8.0.3; port =65432; dbname=XXX; user=XXX; password=XXX");
$res = $db-> query ("SELECT * from user");
if ($res! == false) {
foreach ($res as $row) {
foreach ($row as $key => $value) {
echo ($key. ' => '. $value. '; ');
}
echo ' <br> ';
}
}
} catch (PDOException $ex) {
echo $ex-> getMessage ();
}

[/spoiler]
Answers SQLSTATE [08006 [7] timeout expired
On most SQL the server registered access from a network of 10.8.0.0/24 and 1.2.3.4/32 (exterior IP servers)
PgAdmin it is successfully connected from any PC VPN of a network, i.e. the DB resolves connections
Itself PHP too can work with subnet VPN (the client 10.8.0.8 checked GET request on VPN transits successfully)
I understand that itself PHP  it is guilty, but I do not understand as to trace, at what stage there is an error

2

Re: Connection to PgSQL and data acquisition

wrote:

host=10.8.0.3; port>>> <<<=65432; dbname=X

explicitly superfluous gap.

wlad1164 wrote:

Itself PHP too can work with subnet VPN (the client 10.8.0.8 checked GET request on VPN transits successfully)

I do not see sense to check a connection on an indirect host. Is quite real IP and port of the target server. It is possible though telnet to be knocked. There is no connection - network problems, including a firewall. There is a connection - problems on "the short-range" side (PHP, its units, adjustments, scripts). And VPN there or two computers directly by cable are connected or  through an internal network is connected - at this level of value has no.

3

Re: Connection to PgSQL and data acquisition

vkle, the Gap removed, telnet'
The CLIENT-CLIENT-ANSWER
The SERVER-CLIENT-ANYBODY is not present the house
Went to pick iptables, the decision was:
iptables-t nat-D POSTROUTING-s 10.8.0.0/24-j SNAT - to-source ...
iptables-t nat-A POSTROUTING-o eth0-j SNAT - to-source ...
You were right, thanks for  smile