Squid

提供:onayami

cd /etc/squid/
cp squid.conf squid.conf.org

yum install squid

自動起動設定
$ systemctl enable squid.service
踏み台にされたりしないように、制限はいれておきたい。
デフォルトの部分は基本省略。
#logformat
#ログの時間をみやすくする
logformat squid %tl %>a %Ss/%03>Hs %<st %rm %ru %[un %Sh/%<a %mt

# myproviderは好きな名前をつける。
# ipの場合は、acl myprovider src xxx.xxx.xxx/16
acl myprovider srcdomain <プロバイダのドメイン>

acl SSL_ports port 443
acl Safe_ports port 80          # http
acl Safe_ports port 443         # https
acl Safe_ports port 22          # ssl
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

# 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://localhost/をブロックする、という意味らしい
http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
# 上記で名付けたものしか許可しない
http_access allow myprovider

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

# Squid normally listens to port 3128
# 待受ポートを指定。
http_port 3128

#キャッシュをoff
no_cache deny all

# 接続先にみえるホスト名
visible_hostname xxxx.com

# プロキシサーバーを使用している端末のローカルIPアドレスを隠蔽化
forwarded_for off

# プロキシ経由でアクセスしていることをアクセス先に知られないようにする
# squid3系からは、header_accessではなくrequest_header_accessとする
request_header_access X-Forwarded-For deny all
request_header_access Via deny all
request_header_access Cache-Control deny all


設定が終わったら、起動or反映
systemctl reload squid.service

#ポート空けとfirewallの設定
確認
$ firewall-cmd --list-all
ポート空け
$ firewall-cmd --zone=public --add-port=3128/tcp --permanent
自分のIPしか許可しない
$ firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address="<自分の接続元IP>" port protocol="tcp" port="3128" accept"
※削除するときは、--remove-rich-rule
更新して確認
$ firewall-cmd --reload
$ firewall-cmd --list-all

#ブラウザにプロキシ設定

chromeの場合。
設定 → 詳細設定 → パソコンのプロキシ設定を開く
で、vpsのIPと設定したポートを指定。


systemctl enable squid.service
systemctl start squid.service
systemctl status squid.service

https://www.cman.jp/network/support/go_access.cgi


ssh -i ~/.ssh/private_key.txt -L 31XX:localhost:31XX -p XX -X user@XXX.XXX.XXX.XXX