LoginSignup
7
7

More than 5 years have passed since last update.

DigitalOcean上でさくっとSquidでProxyサーバーを立てる

Last updated at Posted at 2014-04-05

諸事情によりAWS以外に建てたかったので、DigitalOceanに。
月$5ってすごいですよ。

iptables

AWSのSecurityGroupでぬるま湯生活をしていたので、一苦労。

SSH以外にも、3128ポートあけておく。

*filter

:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]

-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 3128 -j ACCEPT

COMMIT
/etc/init.d/iptables restart

iptablesいじるのってちょっと前までは結構恐怖だったんですが、今どきは最悪インスタンス作りなおせばいいので気が楽になりましたね...

CentOS7からはiptablesがデフォルトで動かなくなったので下記参考にしました。

第47回 RHEL7/CentOS7の新規コマンド総まとめ! (中井悦司)
http://www.school.ctc-g.co.jp/columns/nakai/nakai47.html

yum -y install iptables-services
systemctl stop firewalld.service
systemctl mask firewalld.service
systemctl enable iptables.service
systemctl start iptables.service

squid

yum update
yum install squid
/etc/squid/squid.conf
# 使うIPを定義する
acl my_pc               src xxx.xxx.xxx.xxx # your source ip

# http_access deny all よりも手前に
http_access allow my_pc

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

# ファイルの最後に
request_header_access X-Forwarded-For deny all
request_header_access Via deny all
request_header_access Cache-Control deny all
/etc/init.d/squid restart

つなげてテストしてみましょう。

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