Debian 10 で SSL バンピングを使用して Squid 透過プロキシを設定する

Debian 10 で SSL バンピングを使用して Squid 透過プロキシを設定する

Debian 10 はイカを透明プロキシとして使用します。今SSLを追加したいと思います。

# apt-get install openssl
# mkdir -p /etc/squid/cert
# cd /etc/squid/cert
# openssl req -new -newkey rsa:4096 -sha256 -days 365 -nodes -x509 -keyout myCA.pem -out myCA.pem
# openssl x509 -in myCA.pem -outform DER -out myCA.der
# 

# iptables -t nat -A PREROUTING -i br0 -p tcp --dport 443 -j DNAT --to 192.168.1.51:3129
# iptables -t nat -A PREROUTING -i br0 -p tcp --dport 443 -j REDIRECT --to-port 3129
# iptables-save > /etc/iptables/rules.v4

質問1:今、私が読​​んだ内容によれば、次のことを行う必要があります。

/usr/lib/squid/security_file_certgen -c -s /var/cache/squid/ssl_db -M 4MB

security_file_certgen しかし、私のシステムでは見つかりません。

質問2:これを追加すると、次のようになりますsquid.conf

https_port 3129 intercept ssl-bump cert=/etc/squid/cert/myCA.pem generate-host-certificates=on

その後、Squidは起動しません。

2020/10/07 14:09:27| FATAL: Unknown https_port option 'ssl-bump'.
2020/10/07 14:09:27| FATAL: Bungled /etc/squid/squid.conf line 5: https_port 3129 int
2020/10/07 14:09:27| Squid Cache (Version 4.6): Terminated abnormally.
CPU Usage: 0.017 seconds = 0.017 user + 0.000 sys
Maximum Resident Size: 57792 KB
Page faults with physical i/o: 0
FATAL: Bungled /etc/squid/squid.conf line 5: https_port 3129 intercept ssl-bump cert=
squid.service: Control process exited, code=exited, status=1/FAILURE
squid.service: Failed with result 'exit-code'.
Failed to start Squid Web Proxy Server.

squid -v含まれている--enable-ssl-crtdか含まれていないことを確認しましたが、--with-opensslどうすればいいかわかりません。

修正する

この記事を書いている時点では、インターネット上のすべてのガイドは最新バージョンではありません。 https://wiki.squid-cache.org/Features/SslBump ssl-bump
次に置き換えられました https://wiki.squid-cache.org/Features/BumpSslServerFirst server-first そしてserver-first 次に置き換えられました。 https://wiki.squid-cache.org/Features/SslPeekAndSplice peek-n-splice

これがうまくいくことを願っています。始めましょう。https://serverfault.com/questions/743483/transparent-http-https-domain-filtering-proxy :

https_port 3129 intercept ssl-bump
ssl_bump peek all
ssl_bump splice all

しかし:

2020/10/08 09:57:49| FATAL: Unknown https_port option 'ssl-bump'.
2020/10/08 09:57:49| FATAL: Bungled /etc/squid/squid.conf line 6: https_port 3129 int
2020/10/08 09:57:49| Squid Cache (Version 4.6): Terminated abnormally.
CPU Usage: 0.017 seconds = 0.008 user + 0.008 sys
Maximum Resident Size: 57152 KB
Page faults with physical i/o: 0
FATAL: Bungled /etc/squid/squid.conf line 6: https_port 3129 intercept ssl-bump
squid.service: Control process exited, code=exited, status=1/FAILURE
squid.service: Failed with result 'exit-code'.
Failed to start Squid Web Proxy Server.

アップデート:SSLを使用してSquidをコンパイルする

# cd ~
# mkdir squid-build
# cd squid-build
# apt-get install openssh-server net-tools
# apt-get install openssl devscripts build-essential fakeroot libdbi-perl libssl-dev# libssl1.0-dev
# apt-get install dpkg-dev
# apt-get source squid
# apt-get build-dep squid
# cd squid-4.6/
# vi debian/rules
# dpkg-source --commit

debian/rulesファイルにフラグを追加するDEB_CONFIGURE_EXTRA_FLAGS

--with-default-user=proxy \
--enable-ssl \
--enable-ssl-crtd \
--with-openssl \
--disable-ipv6

...そしてビルド...

# debuild -us -uc

...インストールして...

# cd ..
# pwd 
/root/squid-build
# mv squid3*.deb squid3.deb.NotIncluded
# dpkg -i *.deb

しかし、まだ何もありませんssl_crtd

すでに名前を変更しましたかsecurity_file_certgen? (https://bugzilla.redhat.com/show_bug.cgi?id=1397644)

アップデート:イカのコンパイル

HTTP用Squidをコンパイルして実行しましたが、HTTPSで何をすべきかわかりません。明らかに他の人も同じです。できませんか?これは証明書に関連しているようですsquid.conf

ベストアンサー1

私はイカをローカルキャッシュプロキシとして使用しているので、これはあなたの質問に対する直接的な答えではありません。とにかく、あなたの問題が私が必要とした問題に最も近かったので、ここに投稿し、今問題を解決したので共有したいと思います。

Debian 11/Bullseye でインストールするパッケージは次のとおりです。イカopenssl(Squid v4.xコンパイル--with-openssl)。

apt install -y squid-openssl

次に、(自己署名)信頼できるCA証明書を設定します。

CERT_D=/etc/squid/cert
CERT=$CERT_D/squid_proxyCA.pem
rm -rf $CERT
mkdir -p $CERT_D
# Generate local self-signed CA certificate/key (in the same file)
openssl req -new -newkey rsa:4096 -sha256 -days 365 -nodes -x509 -keyout $CERT -out $CERT
chown -R proxy:proxy $CERT_D
chmod 0400 $CERT

# add squid_proxyCA cert to system so it's trusted by default
CA_CERT_D=/usr/local/share/ca-certificates
rm -rf $CA_CERT_D/*
mkdir -p $CA_CERT_D
openssl x509 -inform PEM -in $CERT -out $CA_CERT_D/squid_proxyCA.crt
update-ca-certificates

証明書を動的に生成するようにSquidを設定します。

/usr/lib/squid/security_file_certgen -c -s /var/spool/squid/ssl_db -M 4MB
chown -R proxy:proxy /var/spool/squid

それから私が持っているものは次のとおりです/etc/squid/squid.conf(非常に最小限であり、localhostの接続のみを許可し、IPv4でのみリッスンします)。

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 1025-65535  # unregistered ports

acl purge method PURGE
acl CONNECT method CONNECT

http_access allow manager localhost
http_access deny manager

http_access allow purge localhost
http_access deny purge

http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports

http_access allow localhost
http_access deny all

http_port 127.0.0.1:3128 ssl-bump cert=/etc/squid/cert/squid_proxyCA.pem generate-host-certificates=on options=NO_SSLv3,NO_TLSv1,NO_TLSv1_1,SINGLE_DH_USE,SINGLE_ECDH_USE
ssl_bump bump all

coredump_dir /var/spool/squid
logfile_rotate 0

refresh_pattern -i (/cgi-bin/|\?) 0 0%  0
refresh_pattern .       0   20% 4320

cache_dir ufs /var/spool/squid 200 16 256

最後にイカを再起動してください。

systemctl reload squid

言及する価値があるもう1つのことは、プロキシURLをhttp://127.0.0.1:3028次の目的で使用する必要があることです。両方これhttp_proxyそしてhttps_proxy気づくhttp-いいえ; httpsプロキシとして使用される場合も同様です。 Squidは、httpsで使用されている場合はTLS / SSLを使用するように接続をアップグレードします。

おすすめ記事