Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6340705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:53:13+00:00 2026-05-24T19:53:13+00:00

I have 2 web servers, Server A & Server B. Both running PHP5 +

  • 0

I have 2 web servers, Server A & Server B. Both running PHP5 + Apache + Ubuntu environment.

Server A sends a request via cURL in PHP to Server B. I would like to get the source server domain of the request. As far as I know, $_SERVER['REMOTE_ADDR'] can get the IP of the source server (Server A). If I want to get the domain of Server A, how can I get it?

p.s. Server A hosts multiple domains, thus reverse IP resolve does not work in this case.

Here are the codes :

$data = array('user' => $user, 'pass' => $pass);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://ServerB/handler.php');
curl_setopt($ch, CURLOPT_PORT, 80);
curl_setopt($ch, CURLOPT_VERBOSE, 0); 
curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 

$ans_xml = curl_exec($ch);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:53:14+00:00Added an answer on May 24, 2026 at 7:53 pm
    <?  
    $data = array('user' => $user, 'pass' => $pass, 'appid' => 'pukeko');
    $domain = $_SERVER["SERVER_NAME"]; // user the super global $_SERVER["SERVER_NAME"] or set it  manually to, ex: http://www.myserver.com 
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'http://ServerB/handler.php');
    curl_setopt($ch, CURLOPT_PORT, 80);
    curl_setopt($ch, CURLOPT_VERBOSE, 0); 
    curl_setopt($ch, CURLOPT_HEADER, 0); 
    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_REFERER, $domain); // USE CURLOPT_REFERER to set the referer 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
    
    $ans_xml = curl_exec($ch);
    ?> 
    
    <?
    // ServerB - http://ServerB/handler.php
    $referer = $_SERVER['HTTP_REFERER'];  // http://www.myserver.com 
    ?>
    

    The super global $_SERVER[“SERVER_NAME”] will only work if you call scriptA via apache, ex: “wget http://serverA/scritptA.php“

    UPDATE:

    You can also send $domain = $_SERVER["SERVER_NAME"] in your post data:

    $domain = $_SERVER["SERVER_NAME"]
    $data = array('user' => $user, 'pass' => $pass, 'appid' => 'pukeko', 'icomefrom' => $domain);
    

    and in http://ServerB/handler.php get it with:

    $icomefrom = $_POST['icomefrom'];
    

    This way you don’t have to worry with fake referers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 servers setup at the moment. One is a web server running
I have a SQL Server 2000, C# & ASP.net web app. We want to
Can I have multiple web servers hooked up to a SQL Server cluster and
I have a Linux web server farm with about 5 web servers, web traffic
I have two grails servers: Server - has read/write access to the database Web
I have apache web server installed as frontend and I have j2ee SAP Netweaver
I have a web service running on 3 servers. The woreking is as follows
I have a web server which saves cache files and keeps them for 7
I have a web server that runs my web application. If I want to
I have a web-server, that serves different domain-names, but has only one IP-address assigned.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.