質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Windows 10

Windows 10は、マイクロソフト社がリリースしたOSです。Modern UIを標準画面にした8.1から、10では再びデスクトップ主体に戻され、UIも変更されています。PCやスマホ、タブレットなど様々なデバイスに幅広く対応していることが特徴です。

Squid

Squidは、TCP/IPネットワークでのユーザーとサーバの通信を中継するオープンソースのプロキシサーバソフト。リバースプロキシやキャッシュサーバとして使用することも可能です。

Q&A

解決済

3回答

5220閲覧

squidのブラックリスト指定が反映されない

meito

総合スコア22

Windows 10

Windows 10は、マイクロソフト社がリリースしたOSです。Modern UIを標準画面にした8.1から、10では再びデスクトップ主体に戻され、UIも変更されています。PCやスマホ、タブレットなど様々なデバイスに幅広く対応していることが特徴です。

Squid

Squidは、TCP/IPネットワークでのユーザーとサーバの通信を中継するオープンソースのプロキシサーバソフト。リバースプロキシやキャッシュサーバとして使用することも可能です。

0グッド

0クリップ

投稿2020/10/03 13:00

現在Windows 10の中にSquidをインストールしてURLのブラックリストを指定してフィルタリングをかけようとしています。しかしながら、squid.confとブラックリストを適切に作成したにもかかわらず、ブラックリストがうまく反映しておらず困っています。Windows10環境下でSquid動作の下Webサイトにアクセス化のであることは確認済みです。

具体的にはsquid.confに

## custom acl acl blocked_sites dstdomain '/etc/squid/blocked_sites' http_access deny blocked_sites

を書き込んだだけです。しかしこれでは、ブロッキングができていなかったので、その位置を動かしてみたり、/を(円マーク)に変えてみたりいろいろと試してみましたがどれもうまくいきませんでした。squidのログファイルを"blocked_sites"で検索しても何も出てきていないため、対処法が分からず困っています。

作成したsquid.confとブラックリストのファイルであるblocked_listの内容を下記に記します。

squid.conf # 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 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 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 acl CONNECT method CONNECT # # Recommended minimum Access Permission configuration: # # Only allow cachemgr access from localhost http_access allow localhost manager http_access deny manager # 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 # We strongly recommend the following be uncommented to protect innocent # web applications running on the proxy server who think the only # one who can access services on "localhost" is a local user #http_access deny to_localhost # # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS # # 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 http_access allow localhost # And finally deny all other access to this proxy http_access deny all # Squid normally listens to port 3128 http_port 3128 ## custom acl acl blocked_sites dstdomain '/etc/squid/blocked_sites.txt' http_access deny blocked_sites ############little different############# # Uncomment and adjust the following to add a disk cache directory. #cache_dir ufs /var/cache/squid 100 16 256 # Leave coredumps in the first cache dir coredump_dir /var/cache/squid # # 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 dns_nameservers 8.8.8.8 コード
blocked_site .youtube.com .facebook.com

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

otn

2020/10/03 13:09

Windows環境ですが、「そのsquidからみて/etc がどこに相当するのか」は、ちゃんと把握・認識できていて、その認識が正しいことを確認できていますか?
meito

2020/10/03 13:34

一度それを疑って、絶対パスで通したことがあります。 「'C:\Squid\etc\squid\blocked_sites'」 プログラムを動かしたときにどこからの相対パスを通せばよかったのかについてはいまいちよくわかっていないのですが、絶対パスでもうまくいかなかったので、おそらくこれは原因ではないと思われます。 また、ファイルパスを使わないようなやり方でもブラックリストが読み込まれるか確かめてみましたがうまくいきませんでした。 ### acl douga dstdomain youtube.com http_access deny douga ### たとえば、上記のようなコードをconfig.confの中に挿入してもhttps://www.youtube.comは普通に見れてしまいました。
otn

2020/10/03 13:53

> 一度それを疑って、絶対パスで通したことがあります。 Windowsの絶対パスが処理出来るとは限らないですね。 > たとえば、上記のようなコードを なるほど。
guest

回答3

0

自己解決

結局のところ、Windows環境上での実装をあきらめ代わりにRaspberry Pi 4 にCentOS7をいれたものにsquidを導入し、http_accessの順番を正したら無事に動作しました。

回答者の皆様丁寧に対応していただきありがとうございました。

squid.conf # 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 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 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 acl CONNECT method CONNECT # # Recommended minimum Access Permission configuration: # ## custom acl #http_accessは一番目を満たさないもののうち、二番目の条件を持たすもの、三番目を満たすもの、という感じで適用されますので、ブラックリスト設定は一番上に置くと確実に動きます。 acl blocked_sites dstdomain '/etc/squid/blocked_sites.txt' http_access deny blocked_sites # Only allow cachemgr access from localhost http_access allow localhost manager http_access deny manager # 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 # We strongly recommend the following be uncommented to protect innocent # web applications running on the proxy server who think the only # one who can access services on "localhost" is a local user #http_access deny to_localhost # # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS # # 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 http_access allow localhost # And finally deny all other access to this proxy http_access deny all # Squid normally listens to port 3128 http_port 3128 ############little different############# # Uncomment and adjust the following to add a disk cache directory. #cache_dir ufs /var/cache/squid 100 16 256 # Leave coredumps in the first cache dir coredump_dir /var/cache/squid # # 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 dns_nameservers 8.8.8.8 コード blocked_site .youtube.com .facebook.com

投稿2020/10/10 12:42

編集2020/10/10 12:44
meito

総合スコア22

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

えーとですね、
'/etc/squid/blocked_sites'ファイルを作成してその中身に

blocked_site
.youtube.com
.facebook.com

を、
記載しましょう。

投稿2020/10/03 17:14

hana_yama_san

総合スコア923

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

meito

2020/10/03 22:32

そうしてあります。
hana_yama_san

2020/10/04 10:29

http_access deny blocked_sitesが 反映されていないということですか?
meito

2020/10/04 10:45

はい。
hana_yama_san

2020/10/04 11:08

あのです どうやってWindowsに /etc/squid/blocked_sitesを 作成できたの? 任意のパスに、blocked_sitesを配置して、 コンフィグで指定しないといけないのでは?
meito

2020/10/04 11:48

普通にメモ帳で作りました。 任意のパスでという部分がよく理解できませんでしたが、「blocked_sitesを配置して、コンフィグで指定しないといけない」というのは結局config.confの中でhttp_access deny blocked_sitesをしているので問題ないと思います。 というよりも、blocked_sitesを介さず ### acl douga dstdomain youtube.com http_access deny douga ### としてもうまくいっていないので、ファイルパスの問題ではないと思われます。
guest

0

アクセス元が localhost または localnet に含まれるので許可されているのではないでしょうか?
http_access の順番が意味を持ちます。
http_access だけ抜き出すと、以下の順番に許可/拒否されます。

http_access allow localhost manager http_access deny manager http_access deny !Safe_ports http_access deny CONNECT !SSL_ports http_access allow localnet # ここで許可されているのでは? http_access allow localhost # ここで許可されているのでは? http_access deny all # ここで全拒否 http_access deny blocked_sites # ここは参照されない

allow localnet, allow localhost よりも先に deny blocked_sites を設定するといいのでは?

acl blocked_sites dstdomain '/etc/squid/blocked_sites.txt' http_access deny blocked_sites http_access allow localnet http_access allow localhost http_access deny all

投稿2020/10/03 16:08

TaichiYanagiya

総合スコア12146

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

meito

2020/10/03 22:49

順番を変えて、squidを再起動(一度stopさせてもう一度startさせる)しても変化がありませんでした。 squid.confの中身 squid.conf # 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 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 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 acl CONNECT method CONNECT # # Recommended minimum Access Permission configuration: # # Only allow cachemgr access from localhost http_access allow localhost manager http_access deny manager # 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 # We strongly recommend the following be uncommented to protect innocent # web applications running on the proxy server who think the only # one who can access services on "localhost" is a local user #http_access deny to_localhost # # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS # ## custom acl acl blocked_sites dstdomain '/etc/squid/blocked_sites.txt' http_access deny blocked_sites acl douga dstdomain youtube.com http_access deny douga # 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 http_access allow localhost # And finally deny all other access to this proxy http_access deny all # Squid normally listens to port 3128 http_port 3128 ############little different############# # Uncomment and adjust the following to add a disk cache directory. #cache_dir ufs /var/cache/squid 100 16 256 # Leave coredumps in the first cache dir coredump_dir /var/cache/squid # # 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 dns_nameservers 8.8.8.8 ================== blocked_sitesの中身 .youtube.com .facebook.com
TaichiYanagiya

2020/10/04 05:26

では、ログを確認して、プロキシ経由でアクセスしているか、エラーはないか、確認するといいと思います。
meito

2020/10/04 07:26

windows10のプロキシ設定でプロキシと接続されており、squidの電源もついていることを確認しました。しかしながら、アクセスログを見ると以下のようなメッセージが出ておりました。 2020/10/04 16:21:29 kid1| local=[::1]:3128 remote=[::1]:62601 FD 51 flags=1: read/write failure: (113) Software caused connection abort
TaichiYanagiya

2020/10/04 08:01

ブラウザ -- squid 間の接続に失敗していますね。 ブラウザに原因があるかもしれませんので、切り分けのため、コマンドラインから squidclient (squidclient.exe?) を試してくださいませんでしょうか。 squidclient.exe -p 3128 http://youtube.com/ (IPv6 で接続?) squidclient.exe -h 127.0.0.1 -p 3128 http://youtube.com/ (IPv4 を明示)
meito

2020/10/04 08:56

squidclient.exe -p 3128 http://youtube.com/ (IPv6 で接続?) >>リクエストメッセージが表示されましたが、結局のところERROR_ACCESS_DENIEDとなり接続できておりません。 結局何を確認するべきだったのでしょうか?
TaichiYanagiya

2020/10/04 09:00

blocked_sites へのアクセスで 403 なので、squidclient の場合は所望の結果ですよね? ブラウザに問題があるのかもしれません。
meito

2020/10/04 09:11

MicrosoftEdgeとgooglechromeの両方のブラウザを試してみたのですが、両方とも同じ結果でした。
TaichiYanagiya

2020/10/04 14:15

ログも「read/write failure: (113) Software caused connection abort 」ということですか? であれば、squidclient とブラウザで挙動が違う原因を調べる必要があるのですが、Windows に詳しくないため、ちょっとわかりません。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問