Мои прокси Ipv6 работают на локальном хосте, но не на сервере - PullRequest
0 голосов
/ 02 февраля 2020

Мои прокси не работают на сервере. Он работает плавно, когда я пробую его на localhost.

Сервер: Google Cloud (США - Lowa)
Прокси: США - скорость канала 1 Гбит / с

  • I тестирование с использованием тех же кодов .
  • Я пробовал IPV4, и он работает гладко
  • Я увеличил период ожидания, чтобы не было проблемы с тайм-аутом.
  • Я извлекаю данные из Instagram


Мои коды на localhost:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$url = 'https://www.instagram.com/mechanic.memes/?__a=1';
$proxy = '168.235.93.240';
$port = '39808';
$auth = 'login:password';
$protocol = 'https://';


$proxy = $protocol.$proxy.":".$port;


$header = array();
$header[] = 'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5';
$header[] = 'Cache-Control: max-age=0';
$header[] = 'Content-Type: text/html; charset=utf-8';
$header[] = 'Transfer-Encoding: chunked';
$header[] = 'Connection: keep-alive';
$header[] = 'Keep-Alive: 300';
$header[] = 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7';
$header[] = 'Accept-Language: en-us,en;q=0.5';
$header[] = 'Pragma:';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_REFERER, 'http://www.google.com');
curl_setopt($curl, CURLOPT_PROXY, $proxy);
if($auth != null or $auth != ""){
    curl_setopt($curl, CURLOPT_PROXYUSERPWD, $auth);
}

curl_setopt($curl, CURLOPT_ENCODING, 'gzip, deflate');
curl_setopt($curl, CURLOPT_AUTOREFERER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 300);
$body = curl_exec($curl);


$info = curl_getinfo($curl);
var_dump($info); // Curl Connection Info Dump

curl_close($curl);
var_dump($body); // Curl Data Dump


Результат:

### Information related to my curl connection ###

array(26) { ["url"]=> string(47) "https://www.instagram.com/mechanic.memes/?__a=1" ["content_type"]=> string(31) "application/json; charset=utf-8" ["http_code"]=> int(200) ["header_size"]=> int(2698) ["request_size"]=> int(775) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(0) ["total_time"]=> float(1.888542) ["namelookup_time"]=> float(0.000113) ["connect_time"]=> float(0.275795) ["pretransfer_time"]=> float(1.120533) ["size_upload"]=> float(0) ["size_download"]=> float(998) ["speed_download"]=> float(528) ["speed_upload"]=> float(0) ["download_content_length"]=> float(998) ["upload_content_length"]=> float(-1) ["starttransfer_time"]=> float(1.888475) ["redirect_time"]=> float(0) ["redirect_url"]=> string(0) "" ["primary_ip"]=> string(14) "168.235.93.240" ["certinfo"]=> array(0) { } ["primary_port"]=> int(39808) ["local_ip"]=> string(12) "192.168.1.37" ["local_port"]=> int(58726) }

### The result from Instagram ###

string(2030) "{"logging_page_id":"profilePage_3090893829","show_suggested_profiles":false,"show_follow_dialog":false,"graphql":{"user":{"biography":"Hi, i'm Enrik and i post memes about cars, mechanics, trucks, bikes, airplanes and more...","blocked_by_viewer":false,"country_block":false,"external_url":null,"external_url_linkshimmed":null,"edge_followed_by":{"count":1358172},"followed_by_viewer":false,"edge_follow":{"count":657},"follows_viewer":false,"full_name":"MECHANiC MEMES","has_channel":false,"has_blocked_viewer":false,"highlight_reel_count":0,"has_requested_viewer":false,"id":"3090893829","is_business_account":false,"is_joined_recently":false,"business_category_name":null,"is_private":true,"is_verified":false,"edge_mutual_followed_by":{"count":0,"edges":[]},"profile_pic_url":"https://scontent-lax3-1.cdninstagram.com/v/t51.2885-19/s150x150/50073123_2141335072797197_1027948083826130944_n.jpg?_nc_ht=scontent-lax3-1.cdninstagram.com&_nc_ohc=rdDgqTAO5_QAX8mKuX4&oh=566cb7eabaac24014c7108c3660f3704&oe=5EDBA721","profile_pic_url_hd":"https://scontent-lax3-1.cdninstagram.com/v/t51.2885-19/s320x320/50073123_2141335072797197_1027948083826130944_n.jpg?_nc_ht=scontent-lax3-1.cdninstagram.com&_nc_ohc=rdDgqTAO5_QAX8mKuX4&oh=e2b97f24a30f61fd3a9f15e3518724f8&oe=5EC54A59","requested_by_viewer":false,"username":"mechanic.memes","connected_fb_page":null,"edge_felix_video_timeline":{"count":48,"page_info":{"has_next_page":true,"end_cursor":"QVFCTEoxRjlDaG5ldlpLV1BWYVBJSFpITzlSVGtxX3B0NTdGM2FyS01rdHJPbFhKZ3hGekdUbFludndOel94V3pGczlTY003a1dSUlZIUVZVX3ltUnRYcA=="},"edges":[]},"edge_owner_to_timeline_media":{"count":5030,"page_info":{"has_next_page":true,"end_cursor":"QVFBUGtTQ25oRE15ZUV2UFplbFIxUjZZSXdXTFhXN0hQTF9IYnB3Y2hCN0pYRDNBV2xKcnRxM2w1ZW1jYlVRR2N4ckhaTXJSWnpzRWR3NUw5Sko4ZGlLUQ=="},"edges":[]},"edge_saved_media":{"count":0,"page_info":{"has_next_page":false,"end_cursor":null},"edges":[]},"edge_media_collections":{"count":0,"page_info":{"has_next_page":false,"end_cursor":null},"edges":[]}}},"toast_c


Мои коды на сервере:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$url = 'https://www.instagram.com/mechanic.memes/?__a=1';
$proxy = '168.235.93.240';
$port = '39808';
$auth = 'login:password';
$protocol = 'https://';


$proxy = $protocol.$proxy.":".$port;


$header = array();
$header[] = 'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5';
$header[] = 'Cache-Control: max-age=0';
$header[] = 'Content-Type: text/html; charset=utf-8';
$header[] = 'Transfer-Encoding: chunked';
$header[] = 'Connection: keep-alive';
$header[] = 'Keep-Alive: 300';
$header[] = 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7';
$header[] = 'Accept-Language: en-us,en;q=0.5';
$header[] = 'Pragma:';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_REFERER, 'http://www.google.com');
curl_setopt($curl, CURLOPT_PROXY, $proxy);
if($auth != null or $auth != ""){
    curl_setopt($curl, CURLOPT_PROXYUSERPWD, $auth);
}

curl_setopt($curl, CURLOPT_ENCODING, 'gzip, deflate');
curl_setopt($curl, CURLOPT_AUTOREFERER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 300);
$body = curl_exec($curl);


$info = curl_getinfo($curl);
var_dump($info); // Curl Connection Info Dump

curl_close($curl);
var_dump($body); // Curl Data Dump


Результат сервера:

### Information related to my curl connection ###

array(26) { ["url"]=> string(47) "https://www.instagram.com/mechanic.memes/?__a=1" ["content_type"]=> NULL ["http_code"]=> int(0) ["header_size"]=> int(0) ["request_size"]=> int(0) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(0) ["total_time"]=> float(60.159056) ["namelookup_time"]=> float(2.6E-5) ["connect_time"]=> float(0.060569) ["pretransfer_time"]=> float(0) ["size_upload"]=> float(0) ["size_download"]=> float(0) ["speed_download"]=> float(0) ["speed_upload"]=> float(0) ["download_content_length"]=> float(-1) ["upload_content_length"]=> float(-1) ["starttransfer_time"]=> float(0) ["redirect_time"]=> float(0) ["redirect_url"]=> string(0) "" ["primary_ip"]=> string(14) "168.235.93.240" ["certinfo"]=> array(0) { } ["primary_port"]=> int(39808) ["local_ip"]=> string(10) "10.128.0.9" ["local_port"]=> int(50744)}


### The result from Instagram ### 

bool(false)

Есть ли специальные настройки для ipv6 на сервере? Я не могу понять, почему возникла эта проблема.

Заранее спасибо за ценные ответы

...