LoginSignup
15
11

More than 3 years have passed since last update.

Squidを用いたホワイトリスト方式のURLフィルタリング

Posted at

はじめに

入社1年目の新人エンジニアです。
ホワイトリスト方式のURLフィルタリングを実現するためにSquidを用いました。
その作業内容の備忘録です。

環境

CentOS 7.6.1810
Squid 3.5.20

設定ファイルの作成内容

Squidの設定ファイルを記載します。
プロキシ情報の秘匿は診断くんを用いて確認しました。
  ※結果:「疑惑~20%:proxyの可能性もわずかにあります。」

/etc/squid/squid.conf
# IPv4優先
dns_v4_first on

# IPアドレス定義
acl localnet src 192.168.0.0/16

# 接続先ポートの拒否
acl SSL_ports port 443
acl Safe_ports port 80      # http
acl Safe_ports port 443         # https
acl CONNECT method CONNECT
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports

# アクセス制限(「allow localnet」だとフィルタリングが効かない)
acl whitelist dstdomain "/etc/squid/whitelist"
acl whitelist_regex url_regex "/etc/squid/whitelist_regex"

http_access deny !localnet
http_access allow whitelist
http_access allow whitelist_regex
http_access deny all

# デフォルトのSquid使用ポート
http_port 3128

# キャッシュを用いない
no_cache deny all

# コアファイルの格納する場所
coredump_dir /var/spool/squid

# ホスト名の秘匿
visible_hostname unknown

# プロキシ情報の秘匿
forwarded_for off
request_header_access User-Agent deny all
request_header_access Referer deny all
request_header_access X-Forwarded-For deny all
request_header_access Via deny all
request_header_access Cache-Control deny all

ホワイトリストの内容

ホワイトリスト(ドメインで許可)

Qiitaを閲覧するために必要だったものを記載しました。
.(ドット)から始まるものはサブドメインも含めます。

/etc/squid/whitelist
.qiita.com
.google.com
.gstatic.com
.amazonaws.com
.qiitausercontent.com
qiita-user-profile-images.imgix.net

ホワイトリスト(正規表現)

正規表現のURL単位で許可ができます。

/etc/squid/whitelist_regex
^http://taruo.net/e/

正規表現による許可はHTTPSには利用できませんでした。

おわりに

SSL_Bumpを用いてaccess.logでHTTPSの復号化が確認できましたが、正規表現でのURL許可はできませんでした。
理解が足りず妥協した点があったため、再度調査を行いたいです。

参考サイト

15
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
11