PHP、IPTables 和 Flask 请求

PHP, IPTables, and Request to Flask

=====

更新

我在使用 fsockopen 连接到服务器方面取得了一定程度的成功。但是,如果可能的话,我想使用 cUrl。

=====

原创

我正在尝试使用 post 形式的 curl 向烧瓶发出请求。目标不是使用 jQuery 而是实现更多的信息分离和验证。尽管能够从我的桌面发出请求,但我无法从我的 Web 服务器发出请求。我有 iptables 运行 并在下面列出了规则。另外,我列出了 PHP 代码。我根本没有收到烧瓶的任何输出。

技术:

发出请求的 Go Daddy 托管帐户

Go Daddy vps 用于烧瓶服务器

Iptables:

ACCEPT all -- c-xxx.xxx.xxx anywhere 
ACCEPT all -- ip-xxx.xxx.xxx anywhere

ip 列表来自网络服务器,但 c 列表来自我的桌面。

来自 PHP

的 Curl 请求
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_TIMEOUT, 400);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, True);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);
curl_setopt($ch, CURLOPT_PORT, 8888);
curl_setopt($ch, CURLOPT_POST, count($data));
curl_setopt($ch, CURLOPT_POSTFIELDS, array('url'=>'login','user'=>$user,'pass'=>$pass,'auth'=>$authstring,'ip'=>$ip));

$result = curl_exec($ch);

与来自我的桌面的请求不同,此请求甚至没有使用 tcpdump -i eth0 端口 8888 进行注册。 IP 地址正确。

请求在 Aptana 中运行。

具体错误为:

* Rebuilt URL to: xxx.xx.xx.xx/
* Hostname was found in DNS cache
*   Trying xxx.xx.xx.xx...
* connect to xxx.xx.xx.xx port xx failed: Connection refused
* Failed to connect to xxx.xx.xx.xx port xx: Connection refused
* Closing connection 8

这是在完全刷新我的 iptables 之后。在具有相同 php 版本的 Aptana 中,我得到:

 Trying xxx.xx.xx.xx...
* Adding handle: conn: 0x278fa30
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x278fa30) send_pipe: 1, recv_pipe: 0
* Connected to XXX.XX.XX.XX (XXX.XX.XX.XX) port XXXX (#0)
> POST / HTTP/1.1
Host: xxx.xx.xx.xx:xx
Accept: */*
Content-Length: 29
Content-Type: application/x-www-form-urlencoded

* upload completely sent off: 29 out of 29 bytes
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Content-Type: text/html; charset=utf-8
< Content-Length: 4
< Server: Werkzeug/0.10.4 Python/2.7.5
< Date: Wed, 24 Jun 2015 07:04:28 GMT
<

不幸的是,GoDaddy 的托管代表告诉我只有以下端口对我开放。 80、21 ftp、22 SFTP、445 SSL、3306 mysql。基本上,我不能发送任何东西。我不得不切换托管服务。来自 Go Daddy 的 VPS 也有效。