🧭 Squidで「http_port 8080」と「https_port 8082」を使い分ける

この記事では、http_porthttps_port の違いクライアント側の設定方法運用パターントラブル時の確認ポイントを解説します。

目次

  1. 1. http_port 8080 の動作
  2. 2. https_port 8082 の動作(SSL Bump/透過)
  3. 3. http_porthttps_port の比較表
  4. 4. 実運用のおすすめ構成
  5. 5. クライアント設定の具体例
  6. 6. よくあるハマりどころ(チェックリスト)
  7. 7. サンプル設定(そのまま流用可)
  8. 8. まとめ
  9. 付録:動作確認コマンド

1. http_port 8080 の動作

役割:標準的な HTTPプロキシ。ブラウザ/OSで明示プロキシを設定して利用します。
HTTPSの扱いCONNECT メソッドでトンネルを張り、中身は見えません。

通信フロー(概念)

Client --HTTP--> Squid(http_port) --HTTP/HTTPS--> Web
                └─ HTTPSはCONNECTでトンネル

リクエスト例(ブラウザ→Squid)

GET http://www.example.com/ HTTP/1.1
Host: www.example.com


ポイント


2. https_port 8082 の動作(SSL Bump/透過)

役割TLS(HTTPS)をSquidで終端するためのポート。
主な用途SSL Bump(復号検査)透過HTTPSプロキシ

通信フロー(概念)

Client --TLS(HTTPS)--> Squid(https_port) --TLS/HTTP--> Web
                         └─ 必要に応じて復号(ssl_bump)


ポイント


3. http_porthttps_port の比較表

比較項目 http_port 8080 https_port 8082
主な用途 通常のHTTP/HTTPSプロキシ SSL Bump / 透過HTTPS
クライアント接続 HTTP HTTPS (TLS)
クライアント設定 明示プロキシ 明示 or 透過(FW/NAT必須)
暗号化(Client→Squid) なし(平文) あり(TLS)
証明書配布 不要 必要(中間CA)
HTTPSの中身可視化 不可(CONNECTのトンネル) 可能(bump時)

4. 実運用のおすすめ構成

A. シンプル(HTTPS検査なし)

B. 検査あり(SSL Bump)

C. 透過(ユーザー設定なしで強制プロキシ)


5. クライアント設定の具体例

明示プロキシ(ブラウザ/OS)

透過(Transparent)


6. よくあるハマりどころ(チェックリスト)


7. サンプル設定(そのまま流用可)

7.1 最小構成:明示プロキシ(検査なし)

# /etc/squid/squid.conf
http_port 8080

# 例: 最低限のACL
acl allowed src 192.168.0.0/16
http_access allow allowed
http_access deny all

7.2 併用構成:明示 + SSL Bump

# /etc/squid/squid.conf
http_port 8080

https_port 8082 ssl-bump   cert=/etc/squid/ssl_cert/myCA.pem   key=/etc/squid/ssl_cert/myCA.key   generate-host-certificates=on   dynamic_cert_mem_cache_size=4MB

# Bump ポリシー例
acl step1 at_step SslBump1
ssl_bump peek step1
ssl_bump bump all

# 基本のアクセス制御
acl allowed src 192.168.0.0/16
http_access allow allowed
http_access deny all

# 証明書DB(初回のみ)
# /etc/squid/ssl_cert/ssl_db を作る
# /usr/lib64/squid/security_file_certgen -c -s /etc/squid/ssl_cert/ssl_db -M 4MB

7.3 透過HTTPS(ネットワークで443→8082転送)

# /etc/squid/squid.conf
http_port 3128 intercept
https_port 8082 intercept ssl-bump   cert=/etc/squid/ssl_cert/myCA.pem   key=/etc/squid/ssl_cert/myCA.key   generate-host-certificates=on

acl step1 at_step SslBump1
ssl_bump peek step1
ssl_bump bump all

acl allowed src 192.168.0.0/16
http_access allow allowed
http_access deny all

※ 透過は FW/NATルール が必須。端末のデフォルトゲートウェイ上で実装するのが一般的。


8. まとめ

迷ったら:まずは http_port 8080 単独 で安定させる → その後、要件に応じて https_port(SSL Bump/透過)を段階的に追加するのがおすすめ。


付録:動作確認コマンド(管理端末で)

# HTTP越しにGoogleのヘッダ取得(明示プロキシ8080)
curl -I -x http://192.168.100.205:8080 http://www.google.com

# HTTPSをCONNECTで通す(明示プロキシ8080)
curl -I -x http://192.168.100.205:8080 https://www.google.com

# 直接HTTPSでSquidへ(https_port 8082 にTLSで接続)
openssl s_client -connect 192.168.100.205:8082 -servername www.google.com