nginx是一款强大的反向代理服务器软件,除了作为http服务器和反向代理之外,还可以架设http代理服务器。
配置很简单:
resolver YOUR_RESOLV_IP;
server {
listen proxy_ip:proxy_port;
location / {
proxy_pass http://$http_host$request_uri;
access_log logs/http_proxy.access.log;
error_log logs/http_proxy.error.log;
}
}
=========================================================
wget通过http代理访问:
在服务器上wget之前,设置一下环境变量:
export http_proxy=proxy_ip:proxy_port
wget http://www.qq.com
--16:25:38-- http://www.qq.com/
=> `index.html'
Connecting to proxy_ip:proxy_port... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
[ <=> ] 55,822 121.90K/s
16:25:42 (121.74 KB/s) - `index.html' saved [55822]
大功告成。
===============================================
PHP中如何使用代理发送http请求呢?
一、 使用CURL扩展
二、 使用pecl的http扩展
官网地址:http://pecl.php.net/package/pecl_http
使用方式: