PHP Post Data Over Vpn

PHP Post Data Over VPN

VPNs are at a network layer below PHP, PHP won't know or care that the connection is over a VPN or a normal connection. It's handled by the network stack.

If you use a permanent one (e.g. IPSEC) then PHP doesn't need to create the connection, it's just there to use when PHP connects to an IP address that is in the VPN. It is selected to use by the network layer when it does the routing, not by PHP. This is true even if you create the VPN on demand, as jderda suggested using exec() or similar. But a permanent connection is better (IPSEC).

So to answer your questions:

  1. The question doesn't make sense, the only way PHP could do this is using PPTP or similar and exec() to bring the connection up, but better to use IPSEC
  2. If the VPN connection hangs/dies PHP won't get a connection to the remote end and will timeout the connection.
  3. Yes it is.

AJAX Post Request over VPN stripping request data

Finally was able to resolve this issue recently.

To add a bit of detail missing from the above post, that I only discovered later, the issue was specific to Apple Devices (iOS/OS X).

Looks like there must have been a bug sitting in the Apple OS' preventing the requests from making it all the way through. Updating iOS to iOS 10 and OS X to macOS Sierra has resolved the issue completely.

Get API over VPN with PHP

If you are struggling with api you can use third party library for example guzzle.

And in guzzle you can set proxy server, also for using proxy as you know you should have a proper proxy account wich known with username and password

For example something like this:

$client = new GuzzleHttp\Client();

$res = $client->request("POST", "https://endpoint.com", [
"proxy" => "http://username:password@proxy.ip.address",
]);
this worked with guzzle in php.

Connected through VPN: PHP $_SERVER still gives me local IP

If you are using a VPC, then there is a problem in that the local IP will be used for all communication inside the VPC. The Public IP (EIP I assume) does not exist inside the VPC, it is assigned to the network interface and only translated in the IGW going in or out.

This means that when you check with www.getip.com you get the EIP just as expected since you pass the IGW, but inside the local net you will only see the local IP. Also, PPTP VPN works as it also passes the IGW.

Amazon suggests that you use the FDQN, even if you are on the inside and look up the external FDQN, you will get the local IP.

I do not know how this is in the Classic EC2, but I can only guess its similar.

If you absolutely need to have the public IP, you find it by using the Amazon service for this:

curl http://169.254.169.254/latest/meta-data/public-ipv4

or

curl http://169.254.169.254/latest/meta-data/local-ipv4

(See here: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html)



Related Topics



Leave a reply



Submit