LoginSignup
3
4

More than 5 years have passed since last update.

SquidでProxy環境を作る

Posted at

Proxy環境で何かエラー出たんだけどーという時にデバックするためにぱっと自分でProxy環境を作った時のメモ

構成は以下の様な感じ

サーバーA(squid)<-サーバーB(Proxy経由でのアクセスのみ)

参考

事前準備

  • サーバーBはiptablesなり何らかのFirewallでサーバーAへの接続のみできるようにする

サーバーA(squid)

インストール

$sudo yum install squid

設定ファイルでサーバーBのIPアドレス及び接続許可を追記

/etc/squid/squid.conf

acl source src  xxx.xxx.xxxx.xxx/255.255.255.255 # add

http_access allow source # add

特定のネットワークに対して書いてもOK

/etc/squid/squid.conf

acl source src 172.31.16.0/20 # add

http_access allow source # add

$sudo service squid start

$udo netstat -lanput |grep squid
tcp        0      0 :::3128                     :::*                        LISTEN      8261/(squid)
udp        0      0 0.0.0.0:59636               0.0.0.0:*                               8261/(squid)
udp        0      0 :::36952                    :::*                                    8261/(squid)

あとはアクセスログを適当に監視

$tail -f /var/log/squid/access.log

サーバーB

# 接続できないことを確認
$curl http://yahoo.co.jp

#サーバーAには通信できるか
$ping  xxx.xxx.xxx.xxx

# proxy経由ではアクセスできるのか
$curl --proxy http://xxx.xxx.xxx.xxx:3128 http://yahoo.co.jp

上記タイミングでサーバーAでログも出るので確認。
ログが出てなければそもそも通信ができていないので設定を確認すること

3
4
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
3
4