Amazon Linux 2023 へ Squid をインストールする
ARM 版の Amazon Linux 2023 へ Squid をインストールする手順をメモしておきます。
検証環境
以下の環境で検証しました。
- Amazon Linux 2023
- ARM
- t4g.micro
| # cat /etc/system-release
Amazon Linux release 2023 (Amazon Linux)
|
| # uname -a
Linux ip-192-168-224-239.ap-northeast-1.compute.internal 6.1.66-91.160.amzn2023.aarch64 #1 SMP Wed Dec 13 04:49:48 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux
|
標準リポジトリからインストール
標準リポジトリに Squid のパッケージがありました。 バージョンは 5.8 でした。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 | # dnf info squid
Last metadata expiration check: 1 day, 14:40:27 ago on Mon Jan 1 23:19:32 2024.
Available Packages
Name : squid
Epoch : 7
Version : 5.8
Release : 1.amzn2023.0.3
Architecture : aarch64
Size : 3.0 M
Source : squid-5.8-1.amzn2023.0.3.src.rpm
Repository : amazonlinux
Summary : The Squid proxy caching server
URL : http://www.squid-cache.org
License : GPLv2+ and (LGPLv2+ and MIT and BSD and Public Domain)
Description : Squid is a high-performance proxy caching server for Web clients,
: supporting FTP, gopher, and HTTP data objects. Unlike traditional
: caching software, Squid handles all requests in a single,
: non-blocking, I/O-driven process. Squid keeps meta data and especially
: hot objects cached in RAM, caches DNS lookups, supports non-blocking
: DNS lookups, and implements negative caching of failed requests.
:
: Squid consists of a main server program squid, a Domain Name System
: lookup program (dnsserver), a program for retrieving FTP data
: (ftpget), and some management and client tools.
|
dnf
でインストールします。
インストールされました。
| # systemctl status squid
○ squid.service - Squid caching proxy
Loaded: loaded (/usr/lib/systemd/system/squid.service; disabled; preset: disabled)
Active: inactive (dead)
Docs: man:squid(8)
|
Squid の設定例
設定例は以下の通りです。 Listen するポートをデフォルトの TCP/3128 から TCP/8080 へ変更しています。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 | cat << EOF > /etc/squid/squid.conf
http_port 8080
acl SSL_ports port 443
acl Safe_ports port 80
acl Safe_ports port 443
http_access deny !Safe_ports
http_access allow all
cache deny all
httpd_suppress_version_string on
visible_hostname unknown
forwarded_for off
coredump_dir /var/spool/squid
logformat datefmt %{%Y/%m/%d %H:%M:%S}tl.%03tu %6tr %>a %Ss/%03>Hs %<st %rm %ru %[un %Sh/%<a %mt
access_log daemon:/var/log/squid/access.log datefmt
EOF
|
設定が完了したら Squid を起動&自動起動設定しておきます。
| systemctl start squid.service && systemctl enable squid.service
|
参考
デフォルトの /etc/squid/squid.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84 | #
# Recommended minimum configuration:
#
# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 0.0.0.1-0.255.255.255 # RFC 1122 "this" network (LAN)
acl localnet src 10.0.0.0/8 # RFC 1918 local private network (LAN)
acl localnet src 100.64.0.0/10 # RFC 6598 shared address space (CGN)
acl localnet src 169.254.0.0/16 # RFC 3927 link-local (directly plugged) machines
acl localnet src 172.16.0.0/12 # RFC 1918 local private network (LAN)
acl localnet src 192.168.0.0/16 # RFC 1918 local private network (LAN)
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
acl SSL_ports port 443
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
#
# Recommended minimum Access Permission configuration:
#
# Deny requests to certain unsafe ports
http_access deny !Safe_ports
# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports
# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager
# This default configuration only allows localhost requests because a more
# permissive Squid installation could introduce new attack vectors into the
# network by proxying external TCP connections to unprotected services.
http_access allow localhost
# The two deny rules below are unnecessary in this default configuration
# because they are followed by a "deny all" rule. However, they may become
# critically important when you start allowing external requests below them.
# Protect web applications running on the same server as Squid. They often
# assume that only local users can access them at "localhost" ports.
http_access deny to_localhost
# Protect cloud servers that provide local users with sensitive info about
# their server via certain well-known link-local (a.k.a. APIPA) addresses.
http_access deny to_linklocal
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
# 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
# And finally deny all other access to this proxy
http_access deny all
# Squid normally listens to port 3128
http_port 3128
# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 100 16 256
# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid
#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320
|