允许传入响应 Apache。在 Ubuntu 11.10 上 - Curl

允许传入响应 Apache。在 Ubuntu 11.10 上 - Curl

我正在尝试从外部服务器获取 Curl 响应,但是我注意到我既无法 PING 相关服务器也无法连接到它。

我尝试禁用 iptables 防火墙,但没有成功。我的服务器运行在安装了 DD-wrt ​​固件的 Cisco Linksys WRTN310N 路由器后面。我已经在其中禁用了防火墙。

这是我的网络设置: 配置文件

eth0      Link encap:Ethernet  HWaddr 00:26:b9:76:73:6b
          inet addr:192.168.1.120  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::226:b9ff:fe76:736b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:49713 errors:0 dropped:0 overruns:0 frame:0
          TX packets:30987 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:52829022 (52.8 MB)  TX bytes:5438223 (5.4 MB)
          Interrupt:16

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:341 errors:0 dropped:0 overruns:0 frame:0
          TX packets:341 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:27604 (27.6 KB)  TX bytes:27604 (27.6 KB)

/etc/resolv.conf

nameserver 192.168.1.1

/etc/nsswitch.com

passwd:         compat
group:          compat
shadow:         compat

hosts:          files dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

/etc/主机.conf

order hosts,bind
multi on

/etc/hosts

127.0.0.1       localhost
127.0.0.1       callcenter

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

/etc/网络/接口

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.1.120
        netmask 255.255.255.0
        network 192.168.1.1
        broadcast 192.168.1.255
        gateway 192.168.1.1

我尝试连接的 URL 是 https://www.veripayment.com/integration/index.php 当我在终端上 ping 它时,我得到了以下结果

daniel@callcenter:~$ ping https://www.veripayment.com/integration/index.php
ping: unknown host https://www.veripayment.com/integration/index.php


daniel@callcenter:~$ ping www.veripayment.com
PING www.veripayment.com (69.172.200.5) 56(84) bytes of data.

--- www.veripayment.com ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1007ms

codeigniter 中的 PHP 函数

public function authorizePayment(){
    //---------------------------------------------------
    // Authorize a payment
    //---------------------------------------------------


        // Get variables from POST array
        $post_str = "action=payment&business="      .urlencode($this->input->post('business'))
                    ."&vericode="                   .urlencode($this->input->post('vericode'))
                    ."&item_name="                  .urlencode($this->input->post('item_name'))
                    ."&item_code="                  .urlencode($this->input->post('item_code'))
                    ."&quantity="                   .urlencode($this->input->post('quantity'))
                    ."&amount="                     .urlencode($this->input->post('amount'))
                    ."&cc_type="                    .urlencode($this->input->post('cc_type'))
                    ."&cc_number="                  .urlencode($this->input->post('cc_number'))
                    ."&cc_expdate="                 .urlencode($this->input->post('cc_expdate_year')).urlencode($this->input->post('cc_expdate_month'))
                    ."&cc_security_code="           .urlencode($this->input->post('cc_security_code'))
                    ."&shipment="                   .urlencode($this->input->post('shipment'))
                    ."&first_name="                 .urlencode($this->input->post('first_name'))
                    ."&last_name="                  .urlencode($this->input->post('last_name'))
                    ."&address="                    .urlencode($this->input->post('address'))
                    ."&city="                       .urlencode($this->input->post('city'))
                    ."&state_or_province="          .urlencode($this->input->post('state_or_province'))
                    ."&zip_or_postal_code="         .urlencode($this->input->post('zip_or_postal_code'))
                    ."&country="                    .urlencode($this->input->post('country'))
                    ."&shipping_address="           .urlencode($this->input->post('shipping_address'))
                    ."&shipping_city="              .urlencode($this->input->post('shipping_city'))
                    ."&shipping_state_or_province=" .urlencode($this->input->post('shipping_state_or_province'))
                    ."&shipping_zip_or_postal_code=".urlencode($this->input->post('shipping_zip_or_postal_code'))
                    ."&shipping_country="           .urlencode($this->input->post('shipping_country'))
                    ."&phone="                      .urlencode($this->input->post('phone'))
                    ."&email="                      .urlencode($this->input->post('email'))
                    ."&ip_address="                 .urlencode($this->input->post('ip_address'))
                    ."&website_unique_id="          .urlencode($this->input->post('website_unique_id'));

                    // Send URL string via CURL
                    $backendUrl = "https://www.veripayment.com/integration/index.php";
                    $this->curl->create($backendUrl);
                    $this->curl->post($post_str);
                    $return = $this->curl->execute();

                    $result = array();
                    // Explode array where blanks are found
                    $resparray = explode(' ', $return);

                    if ($resparray)
                    {
                      // save results into an array
                      foreach ($resparray as $resp) {
                        $keyvalue = explode('=', $resp);
                        if(isset($keyvalue[1])){
                        $result[$keyvalue[0]] =  str_replace('"', '', $keyvalue[1]);
                        }
                      }
                    }
                    return $result;

}

这将获得一个空的结果数组。但是,此函数在之前托管该脚本的服务器中运行良好。未进行任何修改

提前致谢

答案1

www.veripayment.com 上的服务器(或其前面的防火墙)配置为丢弃 ping 请求。

C:\Users\RGB> ping www.veripayment.com

Pinging veripayment.com [69.172.200.5] with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 69.172.200.5:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

它响应 HTTP 请求:

C:\Users\RGB> wget http://www.veripayment.com
--22:34:37--  http://www.veripayment.com/
           => `index.html.1'
Resolving www.veripayment.com... done.
Connecting to www.veripayment.com[69.172.200.5]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]

    [ <=>                                 ] 922          900.39K/s

22:34:37 (900.39 KB/s) - `index.html.1' saved [922]


C:\Users\RGB>

对于出站 HTTP 请求,您不需要禁用路由器中的任何防火墙。


更新:

您正在使用 PHP 中的 lib_curl,但是我无法识别它。

curl 的其他 PHP 示例使用类似curl_init()和的函数curl_exec()

我怀疑您需要转储您正在发送的内容(发布数据),比较 PHP 版本并修改代码以检查错误响应。

我不知道您如何使用您正在使用的库来做到这一点,使用其他 PHP curl 库您可以执行以下操作:

if (curl_errno($ch)) {
 print curl_error($ch);
} else {
 curl_close($ch);
}

我会用一些等效的东西来更新 PHP 脚本。

我猜测你的 PHP 版本和环境与旧服务器上的不一样。

相关内容