script runs on server ip-address instead of site ip-address?

redecal

New member
Joined
Jun 8, 2012
Messages
2
Hi There,

If I start an FTP connection in PHP through a cron-job, the remote server detects the IP-Address from my server instead of the ip-address from the virtual site.

How do I change this to the site's IP address? Remote server uses a white-list so the server-ip address is blocked. I would really prefer to do it proper instead of having the server's address whitelisted.

So: is it possible to change the server ip with site ip for scripts/cron-jobs?
 
Hello,

Depending on how do you connect from your PHP script you can make you script to bind to needed IP:

If you use CURL in PHP script:
CURLOPT_INTERFACE The name of the outgoing network interface to use. This can be an interface name, an IP address or a host name.

http://php.net/manual/en/function.curl-setopt.php


And if you use socket see this http://php.net/manual/en/function.socket-bind.php

So: is it possible to change the server ip with site ip for scripts/cron-jobs?
 
Hello,

Depending on how do you connect from your PHP script you can make you script to bind to needed IP:

If you use CURL in PHP script:


http://php.net/manual/en/function.curl-setopt.php


And if you use socket see this http://php.net/manual/en/function.socket-bind.php

thanks, but not exactly what i was looking for.

the job i'm running makes an ftp connection like this, directly in the php script:

$connId = ftp_connect($ftpHost, $ftpServerPort);

script is set to run as cron-job for the site with 'php -f ' command

the remote ftp server identifies the connection coming from the main server ip address and not the ipaddress from the virtual site(s).

remote server is an ftp server using a whitelist for allowed connections as authentication (not my choice, affiliate program so external party, can't change this)
whitelisting my server ip means all sites on this server have access to this server if they run a cron-job or command line ftp command which is something i am trying to avoid.

i can think of more cases where this would apply, connecting to webservice / smtp server etc. if you run a script from a virtual site with dedicated ip i would really prefer this.
 
Back
Top