<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                [TOC] 192.168.56.130 - client 192.168.56.131:3128 - proxy 192.168.56.120:8000 - server(nginx) ## 1. 安裝配置squid(代理) ### 1.1 安裝 ~~~ apt-get update apt-get install -y squid ~~~ ### 1.2. 修改配置文件 ~~~ mkdir -p /var/log/squid chown -R proxy.proxy /var/log/squid mkdir -p /data/squid/cache chown -R proxy.proxy /data/squid/cache ~~~ ~~~ # 設置緩存 cache_mem 1 MB cache_dir aufs /data/squid/cache 10240 32 128 cache_mgr 931309012@qq.com # 訪問日志 access_log daemon:/var/log/squid3/access.log squid cache_log /var/log/squid/cache.log cache_store_log /var/log/squid/store.log acl inner src 192.168.56.0/24 http_access allow inner ~~~ ### 1.3 啟動 1. 啟動 ~~~ service squid3 start ~~~ 2. 查看啟動是有信息(是否有錯誤) ~~~ squid3 -k check ~~~ 3. 查看配置信息 ~~~ squid3 -k parse ~~~ ## 2. 客戶端設置代理 1. 修改/etc/profile文件 這個文件是每個用戶登錄時都會運行的環境變量設置,當用戶第一次登錄時,該文件被執行. 并從/etc/profile.d目錄的配置文件中搜集shell的設置。 ~~~ vim /etc/profile ~~~ ~~~ export http_proxy=192.168.56.131:3128 export https_proxy=$http_proxy ~~~ 2. 刷新/etc/profile文件 ~~~ source /etc/profile ~~~ ## 3. 服務端 服務端就是一個簡單的nginx,開啟了日志,用于查看客戶端ip地址 nginx日志格式 ~~~ log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; ~~~ $remote_addr :遠程請求服務器的ip地址 $remote_user : 用于HTTP基礎認證服務的用戶名 [$time_local] : 時間 $request: 代表客戶端的請求地址 $status :HTTP響應碼 $body_bytes_sent :傳輸給客戶端的字節數,響應頭不計算在內 $http_referer: url跳轉來源,用來記錄從那個頁面鏈接訪問過來的 $http_user_agent:用戶終端瀏覽器等信息 $http_x_forwarded_for: 簡稱XFF頭,它代表客戶端,也就是HTTP的請求端真實的IP,只有在通過了HTTP 代理或者負載均衡服務器時才會添加該項 ### 查看squid訪問日志 ![](https://box.kancloud.cn/7b31a751c65dea5aeda5e58b52e68048_1428x168.png) tail -f /var/log/nginx/logs/access.log ![](https://box.kancloud.cn/7cdc5ebeccc51245a3ee8bdeb1363a66_1257x250.png) 此時,雖然client通過192.168.56.131代理訪問nginx,但是client的真正ip:192.168.56.130也是暴露給了nginx。想要‘匿名’的訪問nginx,則需要對http_x_forwarded_for進行設置。 ~~~ request_header_access X-Forwarded-For deny all request_header_access user-agent deny all ~~~ 重啟squid3(去掉緩存后),再次訪問nginx ![](https://box.kancloud.cn/b225de97dabf6d0326cf0f85ab1eba19_1329x280.png) 此時隱藏了代理設置的 X-Forwarded-For和UserAgent,防止了客戶端ip被暴露。爬蟲代理ip也是如此,通過更換代理ip來保護我們真實的ip。 ## 4. 緩存 squid會對client的請求進行緩存,對于已經緩存過的請求,代理服務器會直接將本地緩存的結果返回給client,效率大大提升。 ### 4.1 client向nginx發起請求 ~~~ curl http://192.168.56.120:8000 # 得到以下響應 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html> ~~~ **nginx日志沒有變化 ,說明剛才客戶端的請求沒有到達nginx,由代理服務器將緩存的index.html返回給了client:** ~~~ tail -f /var/log/nginx/logs/access.log # 沒有變化 ~~~ 在設置的緩存路徑/data/squid/cache/00/00中,多了一個00000000文件,看看這個文件是啥? ![](https://box.kancloud.cn/ea134ef1b4628967dc8af836e3fadfca_571x91.png) ![](https://box.kancloud.cn/9a13f4a11a65a9dc174a230d647a1671_1091x821.png) 對,這就是緩存的nginx首頁HTML代碼。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看