java实现代理ip发请求,请参考:https://my.oschina.net/wuminghai/blog/758082
1. 先检查是否安装了squid。
执行命令:
which squid
2.如果没有装则yum安装squid.
yum install squid
3.修改squid.conf参数。
vi /etc/squid/squid.conf
4.修改后的squid.conf(可根据自己需求更改)
acl localnet src 10.0.0.0/8
acl localnet src fc00::/7
acl localnet src fe80::/10
acl SSL_ports port 443
acl Safe_ports port 80
acl Safe_ports port 443
acl CONNECT method CONNECT
acl NCACHE method GET
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access deny manager
http_access allow all
http_port 8088#指定的端口
no_cache deny NCACHE
forwarded_for off
request_header_access Via deny all
request_header_access X-Forwarded-For deny all
request_timeout 1 minutes
connect_timeout 1 minutes
persistent_request_timeout 1 minutes
half_closed_clients off
acl baidu req_header User-Agent Baiduspider
http_access deny baidu
visible_hostname legalishomo.proxy.com
cache_mgr legalishomo@vip.com
max_open_disk_fds 0
5.创建squid交换目录。
cd /usr/sbin/
./squid -z
6.启动squid.
./squid
7.查看端口状态。
netstat -ntl
8.如何停止呢?
./squid -k shutdown
以上则搞定了squid作为代理的配置。已可以使用。