Squid は、HTTP、HTTPS、FTP などをサポートする Web 用のキャッシング プロキシです。 Squid は、Web プロキシおよびコンテンツ サービス アプリケーションを開発するための豊富なアクセス制御、承認、およびロギング環境を提供します。Squid キャッシュ プロキシ サーバーは、http (ポート 80) 接続をリダイレクトするリバース プロキシとしても構成できます。リバース プロキシとして機能する場合、キャッシュされたコンテンツは、ウェブ サーバーの発信元や内部ネットワーク上のデータを公開することなく、プロキシ サーバーからクライアントに配信されます。
このサービスを含む RPM パッケージ:squid
サービス コントロール
squid サービスを取得するには、yum を使用して squid RPM パッケージをインストールします。
# yum install squid .... Dependencies Resolved ==================================================================================================================== Package Arch Version ==================================================================================================================== Installing: squid x86_64 7:3.5.20-10.el7 Installing for dependencies: libecap x86_64 1.0.0-1.el7 libtool-ltdl x86_64 2.4.2-22.el7_3 perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 perl-DBI x86_64 1.627-4.el7 perl-Data-Dumper x86_64 2.145-3.el7 perl-Digest noarch 1.17-245.el7 perl-Digest-MD5 x86_64 2.52-3.el7 perl-IO-Compress noarch 2.061-2.el7 perl-Net-Daemon noarch 0.48-5.el7 perl-PlRPC noarch 0.2020-14.el7 squid-migration-script x86_64 7:3.5.20-10.el7 Transaction Summary ==================================================================================================================== Install 1 Package (+12 Dependent packages) Total download size: 4.5 M Installed size: 14 M Is this ok [y/d/N]:
将来のシステムのシャットダウンと再起動のために squid サービスを管理するには、chkconfig ツールを使用します:
# chkconfig squid on # chkconfig --list squid squid 0:off 1:off 2:on 3:on 4:on 5:on 6:off # chkconfig squid off
Squid サービスをすぐに制御するには、サービス ツールを使用します。
# service squid Usage: /etc/init.d/squid {start|stop|status|reload|restart|condrestart}
構成
squid の設定ファイルは /etc/squid/squid.conf です:
# cat /etc/squid/squid.conf # WELCOME TO SQUID 2.6.STABLE6 # ---------------------------- # # This is the default Squid configuration file. You may wish # to look at the Squid home page (http://www.squid-cache.org/) # for the FAQ and other documentation. # # The default Squid config file shows what the defaults for # various options happen to be. If you don't need to change the # default, you shouldn't uncomment the line. Doing so may cause # run-time problems. In some cases "none" refers to no default # setting at all, while in other cases it refers to a valid # option - the comments for that keyword indicate if this is the # case. # # NETWORK OPTIONS # ----------------------------------------------------------------------------- # TAG: http_port # Usage: port [options] # hostname:port [options] # 1.2.3.4:port [options] http_port 80 # Port of Squid proxy httpd_accel_host 10.10.1.110 # IP address of web server httpd_accel_port 80 # Port of web server httpd_accel_single_host on # Forward uncached requests to single host httpd_accel_with_proxy on # httpd_accel_uses_host_header off
ここでは、
http_port 80 – ポート 80 は、squid サーバーがリッスンするポートです。
httpd_accel_single_host on – このオプションは、すべてのリクエストが単一のホストに送信されることを squid に通知します。
httpd_accel_host 10.10.1.110 – このアドレスは、Web サーバーのアドレスに変更する必要があります。
httpd_accel_uses_host_header off – このオプションは、クライアントに送信されるコンテンツにプロキシ スタイルのヘッダーを追加しないように squid に指示します。
httpd_accel_port 80 – このアドレスは、リモート Web サーバーがリッスンしているポートです。