CentOS7

squidインストール

プロキシサーバー(Squid)は、一度読み込んだWebページを保存しておき、次回からの同一Webページへのアクセス時には保存してあるWebページをクライアント側に返すことにより、内部からの高速なWebアクセスを可能にするためのサーバー。

インストール

[root@centos ~]# yum -y install squid ← squidインストール

Squid設定

[root@centos ~]# vi /etc/squid/squid.conf ← Squid設定ファイル編集
# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
#acl localnet src 10.0.0.0/8 # RFC1918 possible internal network ←VPS環境の場合コメントアウト
#acl localnet src 172.16.0.0/12 # RFC1918 possible internal network ←VPS環境の場合コメントアウト
#acl localnet src 192.168.0.0/16 # RFC1918 possible internal network ←VPS環境の場合コメントアウト
#acl localnet src fc00::/7 # RFC 4193 local private network range ←IPv4のみ使用する場合コメントアウト
#acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines ←IPv4のみ使用する場合コメントアウト
acl myhost src xxx.xxx.xxx.xxx/32 ←VPS環境の場合、グローバルアドレスを追加
acl myhome src xxx.xxx.xxx.0/24 ←squidへのアクセスを許可するネットワークを追加
acl myoffice src xxx.xxx.xxx.xxx/32 ←squidへのアクセスを許可するIPアドレスを追加

プロキシーアクセスに不要なポートはコメントアウトする
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
acl CONNECT method CONNECT

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !localnet !SSL_ports ← 外部への443番以外のポートへのアクセスを拒否(内部の一部サービスでHTTPSアクセスに443番以外のポートを使用するため。) ただし、上記 acl で localnet をコメントアウトした場合は不要。

# Uncomment and adjust the following to add a disk cache

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
#http_access allow localnet ←上記 acl で localnet を無効にした場合はコメントアウト
http_access allow localhost
http_access allow myhost ←追加
http_access allow myhome ←追加
http_access allow myoffice ←追加

# Squid normally listens to port 3128
http_port 8080 ←ポート番号を変更する場合は修正する

# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /var/spool/squid 100 16 256 ←コメント解除

#
# Add any of your own refresh_pattern entries above these.
#

refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320

--追加(ここから)--
# プロキシ経由アクセスの隠蔽化
visible_hostname unkown
forwarded_for off
request_header_access X-FORWARDED-FOR deny all
request_header_access Via deny all
request_header_access Cache-Control deny all

# アクセスログ設定
logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" >Hs %<st \"%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh
access_log /var/log/squid/access.log combined
--追加(ここまで)--

Squid起動

[root@centos ~]# squid -z ← キャッシュディレクトリ作成
[root@centos ~]# systemctl start squid ← squid起動※CentOS7の場合
[root@centos ~]# systemctl enable squid ← squid自動起動設定※CentOS7の場合

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2020-03-22 (日) 00:32:47