<form id="s48hf"><span id="s48hf"><track id="s48hf"></track></span></form>
    <form id="s48hf"><span id="s48hf"></span></form>
  1. <form id="s48hf"><span id="s48hf"><track id="s48hf"></track></span></form>

      <form id="s48hf"><legend id="s48hf"></legend></form>

      服務項目:網站建設、仿站、程序開發、APP開發設計、移動網站開發設計、企業網站設計、電子商務網站開發、網站維護、網站推廣、UX/UI 、HTML5、CSS3、JS / Jquery ...
      四川???萍加邢薰?></a></div>
                    <div class=四川???萍加邢薰? title=
      四川???萍加邢薰?(開發設計官網)TEL : 15308000360 / QQ : 38585404

      您的位置:旺旺彩票 > 技術經驗 > 服務器 > 正文

      squid tcp_outgoing_address 出口IP隨機調用
      技術支持服務電話:15308000360 【7x24提供運維服務,解決各類系統/軟硬件疑難技術問題】

      squid 代理服務器,使用用戶名和密碼訪問代理,對于出口ip的不同方式的調用或者以隨機的方式調用,因為服務器使用的是squid 2.7版本的,根據官方手冊 3.2版本的有 acl xxx random 1/24 可以隨機(未測試)

      若此篇文章還不能解決您的問題,請聯系QQ:38585404  獲取有償技術服務...

      配置如下

      http_port 142.4.106.1:3128
      http_port 142.4.106.xx:3128
      http_port 142.4.106.xx:3128
      auth_param basic program /user/lib/squid/libexec/ncsa_auth /etc/squid/passwd
      auth_param basic children 5
      auth_param basic realm Squid proxy-caching web server
      auth_param basic credentialsttl 12 hours
      auth_param basic casesensitive off
      #使用用戶或者用戶組來確定出口的IP
      #acl wltony proxy_auth wltony
      #acl wltony1 proxy_auth wltony1
      #tcp_outgoing_address 142.4.106.xxx wltony
      #根據被訪問服務器 IP 來確定出口IP
      #acl no1 myip 142.4.106.xxx
      #tcp_outgoing_address 142.4.106.xxx no1
      acl src_73 src 142.4.106.xxx
      acl src_74 src 142.4.106.xxx
      tcp_outgoing_address 142.4.106.xxx src_73
      tcp_outgoing_address 142.4.106.xxx src_74
      #first_req 為主訪問IP
      acl first_req src 142.4.106.1
      acl second_req src 142.4.106.xxx
      acl second_req src 142.4.106.xxx
      cache_peer 142.4.106.xxx parent 3128 0 round-robin no-query login=wltony:xxx
      cache_peer 142.4.106.xxx parent 3128 0 round-robin no-query login=wltony:xxx
      cache_peer_access 142.4.106.xxx allow first_req
      cache_peer_access 142.4.106.xxx allow first_req
      cache_peer_access 142.4.106.xxx deny second_req
      cache_peer_access 142.4.106.xxx deny second_req
      never_direct allow first_req
      never_direct deny second_req
      #close cache www.haipai.wang
      acl NCACHE method GET
      no_cache deny NCACHE
      acl ncsa_users proxy_auth REQUIRED
      acl all src all
      header_access Via deny all
      header_access X-Forwarded-For deny all
      http_access allow ncsa_users
      #http_access allow wltony
      #http_access allow wltony1
      http_access deny all


      正向代理: 機器通過該機器訪問外部網絡.
      本例: 使用爬蟲去抓取網絡數據.但抓取過多時會被封IP.于是, 在一個機器上綁定若干個 IP. 抓取時使用代理.
      當然, 可以使用其它代理機器.但這里旺旺彩票是使用的代理到本機.
       
      在本機上綁定了 4 個 IP. 同時運行四個抓取實例. 每一個都使用代理, 代理到本機不同的端口.

      本機上的 IP 分別是:
      22.55.153.1
      22.55.153.2
      22.55.153.3
      22.55.153.4
       
      分別使用端口:
      22881
      22882
      22883
      22884
       
      squid 配置: /etc/squid/squid.conf:
       
      # 在代理的時候去掉請求頭部.再另行添加代理后的頭部
      forwarded_for delete
      via Deny all
       
      # 允許本機訪問.如果不加,可能不成功
      http_access allow localhost
       
       
      # 定義本機上的各個端口
      acl p1 myport 22881
      acl p2 myport 22882
      acl p3 myport 22883
      acl p4 myport 22884
       
      # 讓 squid 監聽本機的各個端口
      http_port 22881
      http_port 22882
      http_port 22883
      http_port 22884
       
      # 定義從 squid 代理往外的數據, 每個 ip 分別使用哪個端口
      tcp_outgoing_address 22.55.153.1   p1
      tcp_outgoing_address 22.55.153.2   p2
      tcp_outgoing_address 22.55.153.3   p3
      tcp_outgoing_address 22.55.153.4   p4
       
       
      把上面的配置加到當前的配置文件上部即可.
       
      配置完后重啟 squid 服務.
       
      然后再配置爬蟲軟件使用代理,使用相應的 IP 和端口.
      當使用 22881 端口時, 出口使用的 IP 是 ip1.
      按上面的 tcp_outgoing_address  配置的規則.
      依此類推, 這樣, 同時運行四個任務,實際上出去的 IP 就是四個. 就不會被封了. 



      上一篇:nginx+php-fpm性能參數優化(配置文件)
      下一篇:CentOS下一張網卡設置多個IP

      相關熱詞搜索:squid 隨機IP
      旺旺彩票