2
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

透過Proxyを設定したら証明書なしに何故か動いちゃった話

Posted at

こちらの投稿
Squid proxy - a short guide (forward & transparent proxy examples, SSL bumping, links to guides) -Reddit
などを参考にSquidで透過Proxyの設定をしたら,自己署名ルート証明書を追加せずに動いちゃった話です。

環境

PC: ThinkPad T490 Arch Linux
認証付きProxy必須の環境
Azure上に構築したHTTP ProxyをSSHポートフォワーディングで持ってきている
create_apでWi-Fiを飛ばしていて,スマホはDronyを使いHTTP Proxy非対応のアプリもProxy経由で通信できるようにしている

Squidで複数のProxyを操る -Qiita より

設定ファイルとか

proxy.server.jp:8080(仮)と0.0.0.0:8888を親に持つSquidの設定ファイル:

/etc/squid/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 0.0.0.1-0.255.255.255  # RFC 1122 "this" network (LAN)
acl localnet src 10.0.0.0/8             # RFC 1918 local private network (LAN)
acl localnet src 100.64.0.0/10          # RFC 6598 shared address space (CGN)
acl localnet src 169.254.0.0/16         # RFC 3927 link-local (directly plugged) machines
acl localnet src 172.16.0.0/12          # RFC 1918 local private network (LAN)
acl localnet src 192.168.0.0/16         # RFC 1918 local private network (LAN)
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:
#
# 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

# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager

on_unsupported_protocol tunnel all
# 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
#

cache_peer proxy.server.jp parent 8080 0 no-query no-netdb-exchange no-digest login=USER:PASS
proxy-only
cache_peer 0.0.0.0    parent 8888 0 no-query no-netdb-exchange no-digest default

acl sorting time SMTWHF 1:00-6:00
acl blacklist dstdomain "/usr/local/etc/squid/blacklist"
acl blog url_regex blog
acl blacklist_day dstdomain "/usr/local/etc/squid/blacklist_day"

acl status http_status !200

http_port 7080 intercept
https_port 7443 intercept ssl-bump \
 generate-host-certificates=on \
 dynamic_cert_mem_cache_size=4MB \
 cert=/etc/squid/cert/myCA.pem \
 key=/etc/squid/cert/myCA.pem

acl step1 at_step SslBump1
acl step2 at_step SslBump2
acl step3 at_step SslBump3

#ssl_bump peek step1    # <- enabling this breaks it
ssl_bump stare step2
ssl_bump bump step3
# Uncommenting this may also break bumping.
#ssl_bump bump all
# 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
http_access allow all


# And finally deny all other access to this proxy
http_access deny all

# Squid normally listens to port 3128
http_port 3354
icp_port 0

# 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

# サブProxyがあれば設定

# ローカルネットワークセグメントには親プロキシを通さずダイレクトアクセス
acl developersegments1 dst 192.168.0.0/24
always_direct allow developersegments1

never_direct allow all

# キャッシュしない
cache deny all

#cache_peer_access proxy.server.jp deny sorting
cache_peer_access proxy.server.jp deny blacklist sorting
cache_peer_access proxy.server.jp deny blog sorting
cache_peer_access proxy.server.jp deny blacklist_day
cache_peer_access proxy.server.jp deny status

iptablesで追加した設定
ap0に端末(スマートフォン)が接続されている

iptables -t nat -A PREROUTING -i ap0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 7080
iptables -t nat -A PREROUTING -i ap0 -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 7443

理由

†原因究明中†

2
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?