差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

兩邊的前次修訂版 前次修改
下次修改
前次修改
tech:squid [2018/12/03 12:35] Jonathan Tsaitech:squid [2024/09/26 17:57] (目前版本) – 新增 0-Day Vulnerabilities 警告訊息 jonathan
行 1: 行 1:
 ====== Squid Proxy Server 安裝設定 ====== ====== Squid Proxy Server 安裝設定 ======
-以下是在 CentOS 7 底下安裝與設定 Squid Proxy Server 
  
-===== - 安裝程序 ===== +<WRAP center round important 60%> 
-<code>+  * 因為在 OpenVAS 主機弱掃會出現 **Squid Multiple 0-Day Vulnerabilities (Oct 2023)** 
 +  * 目前改用 [[tech/tinyproxy]] 來替代 Squid 
 +</WRAP> 
 + 
 +====== 使用 docker compose 方式 ===== 
 +  * 採用 [[https://hub.docker.com/r/ubuntu/squid|ubuntu/squid 版本]] <cli> 
 +vi docker-compose.yml 
 +</cli><file> 
 +services: 
 +  squid: 
 +    image: ubuntu/squid:latest 
 +    hostname: squid 
 +    container_name: squid 
 +    environment:  
 +      - TZ=Asia/Taipei 
 +    ports: 
 +      - 3128:3128 
 +    # volumes: 
 +    #   - './conf/squid.conf:/etc/squid/squid.conf:ro' 
 +    #   - './conf/passwords:/etc/squid/passwords:ro' 
 +    restart: always 
 +</file><cli> 
 +docker compose up -d 
 +</cli> 
 +  - 將 squid.conf 掛出來進行後續設定編輯 <cli> 
 +mkdir -p conf 
 +docker cp squid:/etc/squid/squid.conf ./conf/ 
 +</cli> 
 +  - 修改 docker-compose.yml <file> 
 +services: 
 +  squid: 
 +    image: ubuntu/squid:latest 
 +    hostname: squid 
 +    container_name: squid 
 +    environment: 
 +      - TZ=Asia/Taipei 
 +    ports: 
 +      - 3128:3128 
 +    volumes: 
 +      - './conf/squid.conf:/etc/squid/squid.conf:ro' 
 +    #   - './conf/passwords:/etc/squid/passwords:ro' 
 +    restart: always 
 +</file> 
 +  - 修改 squid.conf <cli> 
 +vi ./conf/squid.conf</cli><file> 
 +
 +acl localnet src fe80::/10              # RFC 4291 link-local (directly plugged) machines 
 + 
 +acl SSL_ports port 443 8006 
 +acl Safe_ports port 8006        # PVE manager 
 +acl Safe_ports port 80          # http 
 +acl Safe_ports port 21          # ftp 
 +acl Safe_ports port 443         # https 
 +
 +# For example, to allow access from your local networks, you may uncomment the 
 +# following rule (and/or add rules that match your definition of "local"): 
 +http_access allow localnet 
 +
 +</file> 
 +  * 重新啟動 docker compose <cli> 
 +docker compose restart 
 +</cli> 
 + 
 +==== Q1 : 如果要修改 container 內的 /etc/hosts ==== 
 +  * 參考 - https://stackoverflow.com/questions/74014600/custom-etc-hosts-file-in-dockerfile 
 +  - 將 docker-compose.yml 內加上 extra_hosts: 
 +  - 加上要指定的 hostname 與 IP 資訊 Exp. "www.ichiayi.com:192.168.11.133" "web.ichiayi.com:192.168.11.134" 
 +  - 範例如下:<file> 
 +services: 
 +  squid: 
 +    image: ubuntu/squid:latest 
 +    hostname: squid 
 +    container_name: squid 
 +    environment: 
 +      - TZ=Asia/Taipei 
 +    extra_hosts: 
 +      - "www.ichiayi.com:192.168.11.133"  
 +      - "web.ichiayi.com:192.168.11.134" 
 +    ports: 
 +      - 3128:3128 
 +    volumes: 
 +      - './conf/squid.conf:/etc/squid/squid.conf:ro' 
 +    #   - './conf/passwords:/etc/squid/passwords:ro' 
 +    restart: always 
 +</file> 
 +  - 重啟 docker compose <cli> 
 +docker compose up -d 
 +</cli> 
 + 
 + 
 +====== 一般安裝程序 ====== 
 +以下是在 CentOS 7 與 Ubuntu 20.04 底下安裝與設定 Squid Proxy Server 
 +==== Ubuntu 20.04 ==== 
 +<cli> 
 +sudo -i 
 +apt install squid 
 +apt list -a squid 
 +</cli> 
 +<cli> 
 +root@iiidevops1:~# apt list -a squid 
 +Listing... Done 
 +squid/focal-updates,focal-security,now 4.10-1ubuntu1.2 amd64 [installed] 
 +squid/focal 4.10-1ubuntu1 amd64 
 +</cli> 
 + 
 +==== CentOS 7 ==== 
 +<cli>
 su - root su - root
 yum install -y squid httpd-tools yum install -y squid httpd-tools
-</code+</cli
-<file>+<cli>
 [root@ct-squid ~]# rpm -q squid [root@ct-squid ~]# rpm -q squid
 squid-3.5.20-12.el7.x86_64 squid-3.5.20-12.el7.x86_64
-</file>+</cli>
  
-===== 設定參數檔 =====+===== 設定參數檔 =====
   * 允許 ftp 的 Proxy 功能   * 允許 ftp 的 Proxy 功能
   * 允許 https 使用 port 7443 的 SSL Proxy 功能   * 允許 https 使用 port 7443 的 SSL Proxy 功能
行 35: 行 140:
 </code> </code>
  
-  * 如果要讓所有的 IP (公開的 proxy) 都可存取, 可以增加以下的設定<code file>+  * 如果要讓所有的 IP (公開的 proxy) 都可存取, 可以增加以下的設定<file>
 : :
 # all networks # all networks
行 45: 行 150:
 # And finally deny all other access to this proxy # And finally deny all other access to this proxy
 : :
-</code>+</file>
  
-  * 如果需要設定 Proxy 使用者的帳號密碼, 就執行以下這部分<code sh>+  * 如果需要設定 Proxy 使用者的帳號密碼, 就執行以下這部分<cli>
 vi /etc/squid/squid.conf vi /etc/squid/squid.conf
-</code><file>+</cli><file>
  
 : :
行 58: 行 163:
 : :
 </file> </file>
-  * 第一次建立帳號<code sh>+  * 第一次建立帳號<cli>
 htpasswd -c /etc/squid/passwd jonathan htpasswd -c /etc/squid/passwd jonathan
-</code+</cli
-  * 之後建立帳號或修改密碼<code sh>+  * 之後建立帳號或修改密碼<cli>
 htpasswd /etc/squid/passwd tryweb htpasswd /etc/squid/passwd tryweb
-</code>+</cli>
  
-===== 第一次啟動與設定自動啟動 ===== +===== 第一次啟動與設定自動啟動 ===== 
-<code+<cli
-systemctl start squid.service+systemctl restart squid.service
 systemctl enable squid.service systemctl enable squid.service
-chkconfig --list | grep squid +</cli>
-</code> +
-<file> +
-[root@tryboxap01 squid]# service squid start +
-init_cache_dir /var/spool/squid... 啟動 squid:           [  確定 +
-[root@tryboxap01 squid]# +
-[root@tryboxap01 squid]# chkconfig squid on +
-[root@tryboxap01 squid]# chkconfig --list | grep squid +
-squid           0:off   1:off   2:on    3:on    4:on    5:on    6:off +
-[root@tryboxap01 squid]# +
-</file>+
  
-<note>+<WRAP center round tip 60%>
   * 要瞭解 Proxy 被存取狀況可以看  /var/log/squid/access.log 內容紀錄   * 要瞭解 Proxy 被存取狀況可以看  /var/log/squid/access.log 內容紀錄
   * 通常無法正常啟動可以依據 systemctl status squid.service 的顯示看到問題與解決方案   * 通常無法正常啟動可以依據 systemctl status squid.service 的顯示看到問題與解決方案
-</note> +</WRAP>
- +
- +
-===== - 相關參考資料 =====+
  
-{{topic>squid proxy}}+===== 相關參考資料 =====
   * http://spyker729.blogspot.com/2011/01/ubuntusquid-proxy-server.html   * http://spyker729.blogspot.com/2011/01/ubuntusquid-proxy-server.html
 +  * https://hub.docker.com/r/ubuntu/squid
 +  * https://www.gushiciku.cn/pl/pXRg/zh-tw
  
 {{tag>squid proxy 安裝}} {{tag>squid proxy 安裝}}
  • tech/squid.1543811759.txt.gz
  • 上一次變更: 2018/12/03 12:35
  • Jonathan Tsai