「Squid」:修訂間差異
跳至導覽
跳至搜尋
第33行: | 第33行: | ||
<syntaxhighlight lang="squid"> | <syntaxhighlight lang="squid"> | ||
access_log daemon:/var/log/squid/access.log squid rotate=7 | access_log daemon:/var/log/squid/access.log logformat=squid rotate=7 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
於 2020年12月23日 (三) 04:08 的修訂
Squid是一套Proxy軟體。
安裝
在Ubuntu 18.04上可以直接透過系統的套件裝Squid 3.5版:
sudo apt install -y squid
範例
Forward Proxy
在/etc/squid/squid.conf
裡:
#
acl whitelist dstdom_regex "/etc/squid/whitelist.txt"
http_access allow whitelist
http_access deny all
#
access_log none
cache deny all
cache_dir null /tmp
cache_log /dev/null
cache_mem 8 MB
forwarded_for off
http_port 3128
其中有些欄位可以調整:
access_log daemon:/var/log/squid/access.log logformat=squid rotate=7
在/etc/squid/whitelist.txt
裡:
(^|.)archive\.ubuntu\.com$
Reverse Proxy
在/etc/squid/squid.conf
裡:
#
acl all src 0.0.0.0/0
acl PURGE method PURGE
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl localnet src 10.0.0.0/255.0.0.0
#
http_access allow manager localhost
http_access deny manager
http_access allow PURGE localhost
http_access allow PURGE localnet
http_access deny PURGE
http_access deny all
#
access_log daemon:/home/logs/squid/access.log squid
cache_dir aufs /big/cache 358400 32 256 # FIXME
cache_effective_group nogroup
cache_effective_user nobody
cache_log /home/logs/squid/cache.log
cache_mem 1024 MB
cache_peer 10.1.2.3 parent 80 0 no-query round-robin originserver monitorurl=http://host/robots.txt # FIXME
cache_peer 10.1.2.4 parent 80 0 no-query round-robin originserver monitorurl=http://host/robots.txt # FIXME
cache_replacement_policy heap LFUDA # FIXME
cache_store_log daemon:/home/logs/squid/store.log
cache_swap_high 95
cache_swap_low 80
client_db off
coredump_dir /home/logs
follow_x_forwarded_for allow localnet
forwarded_for on
half_closed_clients off
http_port 80 accel defaultsite=default.domain.tld # FIXME
logfile_daemon /usr/local/squid/libexec/logfile-daemon
logfile_rotate 3
maximum_object_size 307200 KB # FIXME
maximum_object_size_in_memory 102400 KB # FIXME
memory_pools_limit 1331 MB # FIXME
minimum_expiry_time 604800 seconds
minimum_object_size 1 KB # FIXME
refresh_pattern . 60 90% 604800 override-expire ignore-reload ignore-no-cache ignore-no-store
store_avg_object_size 10 MB # FIXME
外部連結
- 官方網站 (英文)