0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Docker版 Proxy Server の構築

Last updated at Posted at 2024-07-23

実現したいこと

プライべーとゾーンを持った環境から、外部サイトを参照したいニーズに答え、プロキシサーバをdokcerを使って実現する。

squidとは?

プロキシサーバーを実装するためのソフトウェア。

事前準備

  • docker engin

向いているひと

OSを汚したくないきれい好きな人向け。

Docker構成

ディレクトリ

project
├── compose.yml
├── cash_dir/
└── squid.conf

構成ファイル

compose.yml
services:
  app:
    #image: sameersbn/squid:3.5.27-2
    image: easypi/squid-arm
    restart: always
    volumes:
      - ./squid.conf:/etc/squid/squid.conf
      - ./cash_dir:/var/spool/squid
    ports:
      - "3128:3128"
    networks:
      vpn_net:
networks:
  vpn_net:
    driver: bridge
    driver_opts:
      com.docker.network.enable_ipv6: "false"
    ipam:
      driver: default
      config:
      - subnet: 172.16.238.0/24
squid.conf
acl localnet src 10.0.0.0/8     # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
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
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
http_access allow localnet
http_access allow localhost
http_access allow all
http_port 3128
coredump_dir /var/spool/squid
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern (Release|Packages(.gz)*)$      0       20%     2880
refresh_pattern .               0       20%     4320

実行方法

compose.ymlのディレクトリがある場所まで移動する。
その後、以下のコマンドで起動

docker-compose up -d
docker ps
CONTAINER ID   IMAGE              COMMAND                  CREATED       STATUS       PORTS                                                 NAMES
89fb41ef03dd   easypi/squid-arm   "/usr/sbin/squid -NY…"   4 weeks ago   Up 9 hours   0.0.0.0:3128->3128/tcp, :::3128->3128/tcp, 3130/udp   squid-app-1
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?