virtual host and ip

Discussion in 'Apache' started by meridian_m, Feb 3, 2010.

  1. #1
    Hi,

    I was wondering if anyone could help.
    I've got a linux server with virtual hosts set up with separate ips and domain names on apache2.
    Everything works fine for incoming requests, but when I send an outgoing call (using curl php but am willing to change if necessary) the ip address received by the target is the server's primary ip address.
    I need it to show that it's from the ip address that has been set to the virtual host where the php page is located.
    Any help would be appreciated.

    Thanks,
    Lee
     
    meridian_m, Feb 3, 2010 IP
  2. hostechsupport

    hostechsupport Well-Known Member

    Messages:
    413
    Likes Received:
    23
    Best Answers:
    7
    Trophy Points:
    138
    #2
    Hello,

    The domain get access by the client should show his IP.
     
    hostechsupport, Feb 4, 2010 IP
  3. CodyRo

    CodyRo Peon

    Messages:
    365
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I don't know of a good way to auto detect it (aside from manually parsing server output) but you could use the --interface option of cURL to have it use a specific interface:

    
    curl --interface eth0 http://www.google.com
    
    Code (markup):
     
    CodyRo, Feb 7, 2010 IP
  4. meridian_m

    meridian_m Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi,

    Many thanks. That's great. That's just what I was looking for. I should have known but I've never had to do this before.
    Your instructions led me use the php command
    curl_setopt ($ch, CURLOPT_INTERFACE, "eth0:0");
    Simple as that.
    Many thanks again, I really needed this.

    Lee
     
    meridian_m, Feb 10, 2010 IP