good-arrow’s blog

https://good-arrow.net/

Squid 設定 Basic認証 テンプレート

インストール

sudo apt -y install squid

# htpasswdコマンド
sudo apt -y install apache2-utils


Squid の設定

/etc/squid/squid.conf

acl SSL_ports port 443
acl CONNECT method CONNECT

### ADD start
acl localnet src 10.0.0.0/8     # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network

acl Safe_ports port 80    # http
acl Safe_ports port 21    # ftp
acl Safe_ports port 443   # https
acl Safe_ports port 70    # gopher
acl Safe_ports port 210   # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280   # http-mgmt
acl Safe_ports port 488   # gss-http
acl Safe_ports port 591   # filemaker
acl Safe_ports port 777   # multiling http

acl password proxy_auth REQUIRED
### ADD end

http_access deny !Safe_ports

http_access deny CONNECT !SSL_ports

http_access allow localhost manager
http_access deny manager

include /etc/squid/conf.d/*

### ADD start
auth_param basic program /usr/lib64/squid/ncsa_auth /etc/squid/passwd
http_access allow password
http_access allow localnet
### ADD end

http_access allow localhost

http_access deny all

http_port 8080

coredump_dir /var/spool/squid

refresh_pattern ^ftp:       1440    20% 10080
refresh_pattern ^gopher:    1440    0%  1440
refresh_pattern -i (/cgi-bin/|\?) 0 0%  0
refresh_pattern \/(Packages|Sources)(|\.bz2|\.gz|\.xz)$ 0 0% 0 refresh-ims
refresh_pattern \/Release(|\.gpg)$ 0 0% 0 refresh-ims
refresh_pattern \/InRelease$ 0 0% 0 refresh-ims
refresh_pattern \/(Translation-.*)(|\.bz2|\.gz|\.xz)$ 0 0% 0 refresh-ims
refresh_pattern .       0   20% 4320
# 新規作成
$ htpasswd -c /etc/squid/passwd user

# ユーザー追加
$ htpasswd -b /etc/squid/passwd user2 pass

# ユーザー削除
$ htpasswd -D /etc/squid/passwd user2
sudo systemctl start squid
sudo systemctl enable squid


Windows プロキシの設定

アドレス=http://user:pass@192.168.100.1
ポート=8080