The implementation of the CULR proxy IP address! [Urgent]

Source: Internet
Author: User
The implementation of the CULR proxy IP address! [Urgent] php curl ip proxy

Print $ _ SERVER ['remote _ ADDR ']; obtain the real IP address
$ _ SERVER ['http _ X_FORWARDED_FOR ']; obtains the proxy IP address.



Implement proxy access to the Web site to return webpage content

$ Ip = rand (1,255). '.'. rand (1,255). '.'. rand (1,255). '. rand (1,255 );
$ HeaderArr [] = 'x-FORWARDED-FOR '.': '. $ ip;
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, "http://ip138.com ");
Curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ headerArr );
$ Re = curl_exec ($ ch );
Var_dump ($ re );


This is the code I wrote and is useless.
$ _ SERVER ['remote _ ADDR ']; print out my real IP address
$ _ SERVER ['http _ X_FORWARDED_FOR ']; the printed IP address is my virtual IP address.

The IP address returned by the program can be displayed as the proxy IP address.


Reply to discussion (solution)

Curl_setopt ($ ch, CURLOPT_HTTPPROXYTUNNEL, TRUE );
Curl_setopt ($ ch, CURLOPT_PROXY, $ proxy );

// First, counterfeit source HTTP_REFERER
$ Ch = curl_init (); // Initialization
Curl_setopt ($ ch, CURLOPT_URL, http://www.example.com/); // The page you want to access
Curl_setopt ($ ch, CURLOPT_REFERER, http://www.example.com/); // counterfeit source HTTP_REFERER
Curl_setopt ($ chtml, CURLOPT_RETURNTRANSFER, 1); // whether to display the content
Curl_exec ($ ch); // execute
Curl_close ($ ch); // return to close

// Second, use a proxy
Curl_setopt ($ ch, CURLOPT_PROXY, "http://www.domain.com ");

// Third, counterfeit ip
Curl_setopt ($ ch, CURLOPT_HTTPHEADER, array ('x-FORWARDED-FOR: 8.8.8.8 ', 'client-IP: 8.8.8.8'); // Construct an IP address

Curl_setopt ($ ch, CURLOPT_HTTPPROXYTUNNEL, TRUE );
Curl_setopt ($ ch, CURLOPT_PROXY, $ proxy );

How can this be used? What does $ proxy mean? What value is assigned to it? IP address? Do I need to add a port number?
What should I do?
Define ('is _ proxy', true );
$ Ip = rand (1,255). '.'. rand (1,255). '.'. rand (1,255). '. rand (1,255 );
$ HeaderArr [] = 'x-FORWARDED-FOR '.': '. $ ip;
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, "http://www.liansuo.com/chaxun.php ");
Curl_setopt ($ ch, CURLOPT_HTTPPROXYTUNNEL, TRUE );
Curl_setopt ($ ch, CURLOPT_PROXY, $ proxy );
Curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ headerArr); // Construct an IP address
$ Re = curl_exec ($ ch );
Var_dump ($ re );

I am a little white. could you please give me a white dot?

Although I am a little white, I am not pure white ..

You guys have trouble testing and building again. I tried it yesterday. it's boring to copy it from Baidu.

Print $ _ SERVER ['remote _ ADDR ']; obtain the real IP address
$ _ SERVER ['http _ X_FORWARDED_FOR ']; obtains the proxy IP address.

I want to pretend to print the IP address obtained by $ _ SERVER ['remote _ ADDR ']
The result is that when the program accesses http://ip138.com/, the IP displays a fake IP.

It's almost pure white.

REMOTE_ADDR is the ip address of the machine accessing the website. assume that it is P.
HTTP_X_FORWARDED_FOR is the ip address information sent by P to the website. you can use REMOTE_ADDR to obtain the ip address of the machine requesting P.

If your local machine is P, you can forge HTTP_X_FORWARDED_FOR, but not REMOTE_ADDR.
If you access the website through proxy P, the website will receive an ip address whose REMOTE_ADDR is P, but HTTP_X_FORWARDED_FOR cannot be forged because it is sent by P and is not under your control.

$ _ SERVER ['remote _ ADDR '] source IP address. if it is accessed by a proxy, it is the proxy ip address.
$ _ SERVER ['http _ X_FORWARDED_FOR '] ip address of the machine accessing the proxy

I want $ _ SERVER ['remote _ ADDR '] to print out the IP address of the proxy I set. can this be implemented? Method

I want $ _ SERVER ['remote _ ADDR '] to print out the IP address of the proxy I set. can this be implemented? Method
For details, see #1 or #2. set CURLOPT_PROXY.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.