4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

squid3を使ってubuntuでBasic認証つきサーバー

Posted at

テスト用にぱっとBasic認証つきのサーバーを設置する必要があったため、メモ的に残しておきます。

#動作確認環境
Ubuntu 14.04 64bit版

#squid3をインストールする

sudo apt-get install squid

#パスワードファイルの作成
Apacheのツールを利用し、Basic認証用のパスワードファイルを作成する。

sudo apt-get install apache2-utils

↓ (ユーザ:"proxy", パスワード:"pass"とする場合)

sudo htpasswd -c /etc/squid/.passwd proxy
New password: pass
Re-type new password: pass

#squid3の設定
以下のファイルを編集する。
/etc/squid3/squid.conf

こんな感じに設定した。
IPは環境によって変更が必要そう。
Windowsアップデートの設定など記載してみたが、未確認。
(ひとまず認証つきプロキシとしては動作確認した。)

/etc/squid3/squid.conf

#acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1
acl localnet src 10.1.10.1/255


acl winupdate dstdomain .microsoft.com .windowsupdate.com
acl SSL_ports port 443
acl Safe_ports port 80                # http
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


#######################################################################
# 認証関連
auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid3/.passwd
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
acl password proxy_auth REQUIRED
http_access allow password
#######################################################################

#
# Recommended minimum Access Permission configuration:
#
# Deny requests to certain unsafe ports
http_access allow localhost manager
http_access allow winupdate
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access allow localnet
http_access deny all

# Squid normally listens to port 3128
http_port 8080


cache_dir ufs /var/spool/squid3 600 16 256
coredump_dir /var/spool/squid3

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

forwarded_for off


request_header_access Referer deny all
request_header_access X-Forwarded-For deny all
request_header_access Via deny all
request_header_access Cache-Control deny all

access_log /var/log/squid3/access.log common

cache_mem 256 MB

#設定の反映

squid3を再起動して設定を反映する。

sudo service squid3 restart
4
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
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?