#author("2020-03-22T00:32:05+09:00","default:egashira","egashira")
#author("2020-03-22T00:32:47+09:00","default:egashira","egashira")
[[CentOS7]]

*squidインストール [#t96fa0a9]
プロキシサーバー(Squid)は、一度読み込んだWebページを保存しておき、次回からの同一Webページへのアクセス時には保存してあるWebページをクライアント側に返すことにより、内部からの高速なWebアクセスを可能にするためのサーバー。

**インストール [#cc8d0faf]
|BGCOLOR(black):COLOR(white):|c
|[root@centos ~]# yum -y install squid &color(lime){← squidインストール};|

**Squid設定 [#t902fb74]
|BGCOLOR(black):COLOR(white):|c
|[root@centos ~]# vi /etc/squid/squid.conf &color(lime){← Squid設定ファイル編集};|
|# Example rule allowing access from your local networks. &br; # Adapt to list your (internal) IP networks from where browsing &br; # should be allowed &br; #acl localnet src 10.0.0.0/8    # RFC1918 possible internal network &color(lime){←VPS環境の場合コメントアウト}; &br; #acl localnet src 172.16.0.0/12 # RFC1918 possible internal network &color(lime){←VPS環境の場合コメントアウト}; &br; #acl localnet src 192.168.0.0/16        # RFC1918 possible internal network &color(lime){←VPS環境の場合コメントアウト}; &br; #acl localnet src fc00::/7       # RFC 4193 local private network range &color(lime){←IPv4のみ使用する場合コメントアウト}; &br; #acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines &color(lime){←IPv4のみ使用する場合コメントアウト}; &br; acl myhost src xxx.xxx.xxx.xxx/32 &color(lime){←VPS環境の場合、グローバルアドレスを追加}; &br; acl myhome src xxx.xxx.xxx.0/24 &color(lime){←squidへのアクセスを許可するネットワークを追加}; &br; acl myoffice src xxx.xxx.xxx.xxx/32 &color(lime){←squidへのアクセスを許可するIPアドレスを追加}; &br; &br; &color(lime){プロキシーアクセスに不要なポートはコメントアウトする}; &br; acl SSL_ports port 443 &br; acl Safe_ports port 80          # http &br; #acl Safe_ports port 21         # ftp &br; acl Safe_ports port 443         # https &br; #acl Safe_ports port 70         # gopher &br; #acl Safe_ports port 210                # wais &br; acl Safe_ports port 1025-65535  # unregistered ports &br; #acl Safe_ports port 280                # http-mgmt &br; #acl Safe_ports port 488                # gss-http &br; #acl Safe_ports port 591                # filemaker &br; #acl Safe_ports port 777                # multiling http &br; acl CONNECT method CONNECT &br; &br; # Deny CONNECT to other than secure SSL ports &br; http_access deny CONNECT &color(lime){!localnet}; !SSL_ports &color(lime){← 外部への443番以外のポートへのアクセスを拒否(内部の一部サービスでHTTPSアクセスに443番以外のポートを使用するため。)}; &color(lightpink){ただし、上記 acl で localnet をコメントアウトした場合は不要。}; &br; &br; # Uncomment and adjust the following to add a disk cache &br; &br; # Example rule allowing access from your local networks. &br; # Adapt localnet in the ACL section to list your (internal) IP networks &br; # from where browsing should be allowed &br; #http_access allow localnet &color(lightpink){←上記 acl で localnet を無効にした場合はコメントアウト}; &br; http_access allow localhost &br; http_access allow myhost &color(lime){←追加}; &br; http_access allow myhome &color(lime){←追加}; &br; http_access allow myoffice &color(lime){←追加}; &br; &br; # Squid normally listens to port 3128 &br; http_port 8080 &color(lime){←ポート番号を変更する場合は修正する}; &br; &br; # Uncomment and adjust the following to add a disk cache directory. &br; cache_dir ufs /var/spool/squid 100 16 256 &color(lime){←コメント解除}; &br; &br; # &br; # Add any of your own refresh_pattern entries above these. &br; # &br; &br; refresh_pattern ^ftp:           1440    20%     10080 &br; refresh_pattern ^gopher:        1440    0%      1440 &br; refresh_pattern -i (/cgi-bin/|\?) 0     0%      0 &br; refresh_pattern .               0       20%     4320 &br; &br; &color(lime){--追加(ここから)--}; &br; &color(lime){# プロキシ経由アクセスの隠蔽化}; &br; visible_hostname unkown &br; forwarded_for off &br; request_header_access X-FORWARDED-FOR deny all &br; request_header_access Via deny all &br; request_header_access Cache-Control deny all &br; &br; &color(lime){# アクセスログ設定}; &br;logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" >Hs %<st \"%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh
access_log /var/log/squid/access.log combined &br; &color(lime){--追加(ここまで)--};|
|# Example rule allowing access from your local networks. &br; # Adapt to list your (internal) IP networks from where browsing &br; # should be allowed &br; #acl localnet src 10.0.0.0/8    # RFC1918 possible internal network &color(lime){←VPS環境の場合コメントアウト}; &br; #acl localnet src 172.16.0.0/12 # RFC1918 possible internal network &color(lime){←VPS環境の場合コメントアウト}; &br; #acl localnet src 192.168.0.0/16        # RFC1918 possible internal network &color(lime){←VPS環境の場合コメントアウト}; &br; #acl localnet src fc00::/7       # RFC 4193 local private network range &color(lime){←IPv4のみ使用する場合コメントアウト}; &br; #acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines &color(lime){←IPv4のみ使用する場合コメントアウト}; &br; acl myhost src xxx.xxx.xxx.xxx/32 &color(lime){←VPS環境の場合、グローバルアドレスを追加}; &br; acl myhome src xxx.xxx.xxx.0/24 &color(lime){←squidへのアクセスを許可するネットワークを追加}; &br; acl myoffice src xxx.xxx.xxx.xxx/32 &color(lime){←squidへのアクセスを許可するIPアドレスを追加}; &br; &br; &color(lime){プロキシーアクセスに不要なポートはコメントアウトする}; &br; acl SSL_ports port 443 &br; acl Safe_ports port 80          # http &br; #acl Safe_ports port 21         # ftp &br; acl Safe_ports port 443         # https &br; #acl Safe_ports port 70         # gopher &br; #acl Safe_ports port 210                # wais &br; acl Safe_ports port 1025-65535  # unregistered ports &br; #acl Safe_ports port 280                # http-mgmt &br; #acl Safe_ports port 488                # gss-http &br; #acl Safe_ports port 591                # filemaker &br; #acl Safe_ports port 777                # multiling http &br; acl CONNECT method CONNECT &br; &br; # Deny CONNECT to other than secure SSL ports &br; http_access deny CONNECT &color(lime){!localnet}; !SSL_ports &color(lime){← 外部への443番以外のポートへのアクセスを拒否(内部の一部サービスでHTTPSアクセスに443番以外のポートを使用するため。)}; &color(lightpink){ただし、上記 acl で localnet をコメントアウトした場合は不要。}; &br; &br; # Uncomment and adjust the following to add a disk cache &br; &br; # Example rule allowing access from your local networks. &br; # Adapt localnet in the ACL section to list your (internal) IP networks &br; # from where browsing should be allowed &br; #http_access allow localnet &color(lightpink){←上記 acl で localnet を無効にした場合はコメントアウト}; &br; http_access allow localhost &br; http_access allow myhost &color(lime){←追加}; &br; http_access allow myhome &color(lime){←追加}; &br; http_access allow myoffice &color(lime){←追加}; &br; &br; # Squid normally listens to port 3128 &br; http_port 8080 &color(lime){←ポート番号を変更する場合は修正する}; &br; &br; # Uncomment and adjust the following to add a disk cache directory. &br; cache_dir ufs /var/spool/squid 100 16 256 &color(lime){←コメント解除}; &br; &br; # &br; # Add any of your own refresh_pattern entries above these. &br; # &br; &br; refresh_pattern ^ftp:           1440    20%     10080 &br; refresh_pattern ^gopher:        1440    0%      1440 &br; refresh_pattern -i (/cgi-bin/|\?) 0     0%      0 &br; refresh_pattern .               0       20%     4320 &br; &br; &color(lime){--追加(ここから)--}; &br; &color(lime){# プロキシ経由アクセスの隠蔽化}; &br; visible_hostname unkown &br; forwarded_for off &br; request_header_access X-FORWARDED-FOR deny all &br; request_header_access Via deny all &br; request_header_access Cache-Control deny all &br; &br; &color(lime){# アクセスログ設定}; &br;logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" >Hs %<st \"%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh &br; access_log /var/log/squid/access.log combined &br; &color(lime){--追加(ここまで)--};|

**Squid起動 [#i824baa1]
|BGCOLOR(black):COLOR(white):|c
|[root@centos ~]# squid -z &color(lime){← キャッシュディレクトリ作成};|
|[root@centos ~]# systemctl start squid &color(lime){← squid起動※CentOS7の場合};|
|[root@centos ~]# systemctl enable squid &color(lime){← squid自動起動設定※CentOS7の場合};|

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS