Windows Server 2016 へ Squid を導入します。 (※ プロキシ設定は触れません。)

Squid について

4.10 Does Squid support Socks?
We would like to use Squid, but we need it to use socks to connect to the world outside our firewall.

No changes are necessary to use Squid with socks5. Simply add the usual -Dbind=SOCKSbind etc., to the compile line and -lsocks to the link line.

インストールなど

インストール

ダウンロードした squid.msi でインストール。迷う所はありません。各種設定ファイルは C:\Squid\etc\squid\に置かれます。

インストールが完了すると、デスクトップ上にアイコンが作成されます。

  • Squid Server Tray
    • サービスの起動停止、設定ファイルへのリンクを選択できる簡易ツール

  • Squid Terminal
    • Squid ディレクトリで開くコマンドプロンプト

サービスではなく、コマンドでの実行も可能です。

C:\Squid\bin>squid.exe -h
Usage: squid [-cdhvzCFNRVYX] [-n name] [-s | -l facility] [-f config-file] [-[au] port] [-k signal]
       -a port   Specify HTTP port number (default: 3128).
       -d level  Write debugging to stderr also.
       -f file   Use given config-file instead of
                 /etc/squid/squid.conf
       -h        Print help message.
       -k reconfigure|rotate|shutdown|restart|interrupt|kill|debug|check|parse
                 Parse configuration file, then send signal to
                 running copy (except -k parse) and exit.
       -n name   Specify service name to use for service operations
                 default is: squid.
       -s | -l facility
                 Enable logging to syslog.
       -u port   Specify ICP port number (default: 3130), disable with 0.
       -v        Print version.
       -z        Create missing swap directories and then exit.
       -C        Do not catch fatal signals.
       -D        OBSOLETE. Scheduled for removal.
       -F        Don't serve any requests until store is rebuilt.
       -N        No daemon mode.
       -R        Do not set REUSEADDR on port.
       -S        Double-check swap during rebuild.
       -X        Force full debugging.
       -Y        Only return UDP_HIT or UDP_MISS_NOFETCH during fast reload.

サービスは Squid for Windows という名前で作成されます。自動起動も有効化された状態です。

ファイアウォール設定

squid 自体での接続元制限設定が行なえますが、それとは別にファイアウォール設定の必要があります。 Squid Cache Server ルールが作成されているので、適宜設定します。

ログローテーション

ログファイルが C:\Squid\var\log\squid に作成されます。 ログローテーションはコマンド実行で行います。

C:\squid\bin> squid -k rotate

デフォルト10世代(ファイル)です。保存数を変更したい場合は設定ファイルに追記します。

logfile_rotate 10

タスクスケジューラ

Squid 固有というわけではないですが、ログローテーションの定期実行のため、スケジュール実行設定を行います。

C:\>schtasks /create /tn logrotate_squid /tr "C:\Squid\bin\squid.exe -k rotate" /sc weekly /ST 00:00 /rl highest /F /NP
SUCCESS: The scheduled task "logrotate_squid" has successfully been created.

タスクスケジューラの履歴(ログ)

最近のWindowsはタスクスケジューラの履歴取得がデフォルトで無効のようでした。必要に応じて有効化します。

C:\>wevtutil set-log Microsoft-Windows-TaskScheduler/Operational /enabled:true

履歴の実体はイベントビューアーなので、詳細設定(ログ保持量等)はそちらで行います。

  • [Applications and Services Logs] -> [Microsoft] -> [Windows] -> [TaskScheduler] -> [Operational]

元記事はこちら

Windows版Squid導入あれやこれや