輕鬆 簡單 我的備忘錄

關於部落格
記錄生活點點滴滴 想記錄的就記下來 就是這麼簡單
  • 308220

    累積人氣

  • 6

    今日人氣

    0

    訂閱人氣

IE代理伺服器自動切換設定檔

預參考此文章前必備條件:
必需有2台以上代理伺服器,無論是自己架設的還是公司或網路上找的


使用代理伺服器可以加速網路存取速度
當有2個以上代理伺服器時,像我有架設37個代理伺服器
每次要使用其他的就要一個一個修改,實在是很麻煩
 


為什麼要手動切換呢?
因為有時候某幾個代理伺服器會比較忙碌,某幾個就比較閒置
切換到比較閒置的代理伺服器,網路就會變的比較快速
 

 


 

使用自動切換的好處:
1.可以自動的選擇反應較快的伺服器做連線,使用者完全不用理會哪一個較快
2.
假設同一時間,連線到"1"個網站時,
會自動把"1"個網站所有瀏覽檔案分配到每一個代理伺服器上,使網路速度維持平衡,增快瀏覽速度,不至於拖垮網路速度以及去電腦運行速度.
同時瀏覽多個網站時,也很快速
例如:
vaio:8080 ~ vaio:8090
port:8080~8090   共有11個Port
假設同一時間單一網頁要處理1000個檔案時
使用自動設定的好處就是會由系統自動的分配到每個Port的伺服器上,使CPU負荷降低許多

 


 

使用單一代理伺服器的壞處:
1.同一時間瀏覽1個網頁或2個以上網頁時,只有單一代理伺服器可以處理,若網站資料太龐大,假設有1000個資料時,易造成系統繁忙拖垮系統及網路速度
例如:

vaio:8080,只有一個8080 Port,同一時間要處理1000個資料時所帶來的後遺症 

 


 

自動設定檔編輯Sample:
 

 


 

使用方法:
1:以下代碼存成"Proxy.pac"
2.將proxy.pac放到c:下
在IE裡使用自動組態指令碼打勾並設定以下位置:
file://c:/proxy.pac

function FindProxyForURL(url,host)

      {

            return randomProxy();

      }

      function randomProxy()

      {

           switch( Math.floor( Math.random() * 37 ) )

           {

               case 0:

                   return "PROXY localhost:8091; DIRECT";

                   break;

               case 1:

                   return "PROXY localhost:8081; DIRECT";

                   break;

               case 2:

                   return "PROXY localhost:8082; DIRECT";

                   break;

               case 3:

                   return "PROXY localhost:8083; DIRECT";

                   break;

               case 4:

                   return "PROXY localhost:8084; DIRECT";

                   break;


               case 5:

                   return "PROXY localhost:8085; DIRECT";

                   break;

               case 6:

                   return "PROXY localhost:8086; DIRECT";

                   break;

               case 7:

                   return "PROXY localhost:8087; DIRECT";

                   break;

               case 8:

                   return "PROXY localhost:8088; DIRECT";

                   break;

               case 9:

                   return "PROXY localhost:8089; DIRECT";

                   break;

               case 10:

                   return "PROXY localhost:8090; DIRECT";

                   break;

               case 11:

                   return "PROXY localhost:8080; DIRECT";

                   break;

               case 12:

                   return "PROXY vaio:8091; DIRECT";

                   break;

               case 13:

                   return "PROXY vaio:8081; DIRECT";

                   break;

               case 14:

                   return "PROXY vaio:8082; DIRECT";

                   break;

               case 15:

                   return "PROXY vaio:8083; DIRECT";

                   break;

               case 16:

                   return "PROXY vaio:8084; DIRECT";

                   break;


               case 17:

                   return "PROXY vaio:8085; DIRECT";

                   break;

               case 18:

                   return "PROXY vaio:8086; DIRECT";

                   break;

               case 19:

                   return "PROXY vaio:8087; DIRECT";

                   break;

               case 20:

                   return "PROXY vaio:8088; DIRECT";

                   break;

               case 21:

                   return "PROXY vaio:8089; DIRECT";

                   break;

               case 22:

                   return "PROXY vaio:8090; DIRECT";

                   break;

               case 23:

                   return "PROXY vaio:8080; DIRECT";

                   break;

               case 24:

                   return "PROXY jeff-eeepc:8091; DIRECT";

                   break;

               case 25:

                   return "PROXY jeff-eeepc:8081; DIRECT";

                   break;

               case 26:

                   return "PROXY jeff-eeepc:8082; DIRECT";

                   break;

               case 27:

                   return "PROXY jeff-eeepc:8083; DIRECT";

                   break;

               case 28:

                   return "PROXY jeff-eeepc:8084; DIRECT";

                   break;


               case 29:

                   return "PROXY jeff-eeepc:8085; DIRECT";

                   break;

               case 30:

                   return "PROXY jeff-eeepc:8086; DIRECT";

                   break;

               case 31:

                   return "PROXY jeff-eeepc:8087; DIRECT";

                   break;

               case 32:

                   return "PROXY jeff-eeepc:8088; DIRECT";

                   break;

               case 33:

                   return "PROXY jeff-eeepc:8089; DIRECT";

                   break;

               case 34:

                   return "PROXY jeff-eeepc:8090; DIRECT";

                   break;

               case 35:

                   return "PROXY jeff-eeepc:8080; DIRECT";

                   break;

               case 36:

                   return "DIRECT";

                   break;


          }  

      }


說明:

return "PROXY jeff-eeepc:8080; DIRECT;

"PROXY jeff-eeepc:8080 (第一優先順序),DIRECT第二優先順序"
若第一個連線超時Timeout則使用第二優先順序DIRECT

DIRECT (為直接連線不透過PROXY的方式上網)

特此紀錄一下必免忘記了^^
相簿設定
標籤設定
相簿狀態