差異處
這裏顯示兩個版本的差異處。
兩邊的前次修訂版 前次修改 下次修改 | 前次修改 | ||
tech:squid [2018/12/03 12:31] – Jonathan Tsai | tech:squid [2024/09/26 17:57] (目前版本) – 新增 0-Day Vulnerabilities 警告訊息 jonathan | ||
---|---|---|---|
行 1: | 行 1: | ||
+ | ====== Squid Proxy Server 安裝設定 ====== | ||
+ | <WRAP center round important 60%> | ||
+ | * 因為在 OpenVAS 主機弱掃會出現 **Squid Multiple 0-Day Vulnerabilities (Oct 2023)** | ||
+ | * 目前改用 [[tech/ | ||
+ | </ | ||
+ | |||
+ | ====== 使用 docker compose 方式 ===== | ||
+ | * 採用 [[https:// | ||
+ | vi docker-compose.yml | ||
+ | </ | ||
+ | services: | ||
+ | squid: | ||
+ | image: ubuntu/ | ||
+ | hostname: squid | ||
+ | container_name: | ||
+ | environment: | ||
+ | - TZ=Asia/ | ||
+ | ports: | ||
+ | - 3128:3128 | ||
+ | # volumes: | ||
+ | # - ' | ||
+ | # - ' | ||
+ | restart: always | ||
+ | </ | ||
+ | docker compose up -d | ||
+ | </ | ||
+ | - 將 squid.conf 掛出來進行後續設定編輯 <cli> | ||
+ | mkdir -p conf | ||
+ | docker cp squid:/ | ||
+ | </ | ||
+ | - 修改 docker-compose.yml < | ||
+ | services: | ||
+ | squid: | ||
+ | image: ubuntu/ | ||
+ | hostname: squid | ||
+ | container_name: | ||
+ | environment: | ||
+ | - TZ=Asia/ | ||
+ | ports: | ||
+ | - 3128:3128 | ||
+ | volumes: | ||
+ | - ' | ||
+ | # - ' | ||
+ | restart: always | ||
+ | </ | ||
+ | - 修改 squid.conf <cli> | ||
+ | vi ./ | ||
+ | : | ||
+ | acl localnet src fe80::/ | ||
+ | |||
+ | 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 " | ||
+ | http_access allow localnet | ||
+ | : | ||
+ | </ | ||
+ | * 重新啟動 docker compose <cli> | ||
+ | docker compose restart | ||
+ | </ | ||
+ | |||
+ | ==== Q1 : 如果要修改 container 內的 /etc/hosts ==== | ||
+ | * 參考 - https:// | ||
+ | - 將 docker-compose.yml 內加上 extra_hosts: | ||
+ | - 加上要指定的 hostname 與 IP 資訊 Exp. " | ||
+ | - 範例如下:< | ||
+ | services: | ||
+ | squid: | ||
+ | image: ubuntu/ | ||
+ | hostname: squid | ||
+ | container_name: | ||
+ | environment: | ||
+ | - TZ=Asia/ | ||
+ | extra_hosts: | ||
+ | - " | ||
+ | - " | ||
+ | ports: | ||
+ | - 3128:3128 | ||
+ | volumes: | ||
+ | - ' | ||
+ | # - ' | ||
+ | restart: always | ||
+ | </ | ||
+ | - 重啟 docker compose <cli> | ||
+ | docker compose up -d | ||
+ | </ | ||
+ | |||
+ | |||
+ | ====== 一般安裝程序 ====== | ||
+ | 以下是在 CentOS 7 與 Ubuntu 20.04 底下安裝與設定 Squid Proxy Server | ||
+ | ==== Ubuntu 20.04 ==== | ||
+ | <cli> | ||
+ | sudo -i | ||
+ | apt install squid | ||
+ | apt list -a squid | ||
+ | </ | ||
+ | <cli> | ||
+ | root@iiidevops1: | ||
+ | Listing... Done | ||
+ | squid/ | ||
+ | squid/focal 4.10-1ubuntu1 amd64 | ||
+ | </ | ||
+ | |||
+ | ==== CentOS 7 ==== | ||
+ | <cli> | ||
+ | su - root | ||
+ | yum install -y squid httpd-tools | ||
+ | </ | ||
+ | <cli> | ||
+ | [root@ct-squid ~]# rpm -q squid | ||
+ | squid-3.5.20-12.el7.x86_64 | ||
+ | </ | ||
+ | |||
+ | ===== 設定參數檔 ===== | ||
+ | * 允許 ftp 的 Proxy 功能 | ||
+ | * 允許 https 使用 port 7443 的 SSL Proxy 功能 | ||
+ | * 允許 Google Talk 使用 port 5222 的 http Proxy 功能 | ||
+ | * 假設指定只有 來自 61.67.71.0/ | ||
+ | * 允許接受 SVN 的延伸指令 REPORT MERGE MKACTIVITY CHECKOUT | ||
+ | |||
+ | <code |h vi / | ||
+ | : | ||
+ | ftp_user [email protected] | ||
+ | : | ||
+ | acl SSL_ports port 443 7443 | ||
+ | : | ||
+ | acl Safe_ports port 443 # https | ||
+ | acl Safe_ports port 7443 # https-g2b2c | ||
+ | acl Safe_ports port 5222 # GoogleTalk | ||
+ | : | ||
+ | acl our_networks src 61.67.71.0/ | ||
+ | http_access allow our_networks | ||
+ | : | ||
+ | |||
+ | </ | ||
+ | |||
+ | * 如果要讓所有的 IP (公開的 proxy) 都可存取, | ||
+ | : | ||
+ | # all networks | ||
+ | acl all_networks src all | ||
+ | : | ||
+ | # allow all | ||
+ | http_access allow all_networks | ||
+ | |||
+ | # And finally deny all other access to this proxy | ||
+ | : | ||
+ | </ | ||
+ | |||
+ | * 如果需要設定 Proxy 使用者的帳號密碼, | ||
+ | vi / | ||
+ | </ | ||
+ | |||
+ | : | ||
+ | auth_param basic program / | ||
+ | : | ||
+ | acl password proxy_auth REQUIRED | ||
+ | http_access allow password | ||
+ | : | ||
+ | </ | ||
+ | * 第一次建立帳號< | ||
+ | htpasswd -c / | ||
+ | </ | ||
+ | * 之後建立帳號或修改密碼< | ||
+ | htpasswd / | ||
+ | </ | ||
+ | |||
+ | ===== 第一次啟動與設定自動啟動 ===== | ||
+ | <cli> | ||
+ | systemctl restart squid.service | ||
+ | systemctl enable squid.service | ||
+ | </ | ||
+ | |||
+ | <WRAP center round tip 60%> | ||
+ | * 要瞭解 Proxy 被存取狀況可以看 | ||
+ | * 通常無法正常啟動可以依據 systemctl status squid.service 的顯示看到問題與解決方案 | ||
+ | </ | ||
+ | |||
+ | ===== 相關參考資料 ===== | ||
+ | * http:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | |||
+ | {{tag> |