Last-modified: 2011-12-26 (月) 01:24:42
Apache/フォワードプロキシにしたい

概要

Apacheをフォワードプロキシとして動かしてみます。
今回は、yumでApacheをインストールするところから始めて、サクっと動かします。
どこからでも使いたいので、制限はDigest認証のみ設定します。

手順

  1. Apacheをインストールします。
    Everything is expanded.Everything is shortened.
      1
    
     
    
    yum install httpd.x86_64
  2. 「/etc/httpd/conf/httpd.conf」を開きます。
    コメントを解除して、プロキシを有効にします。
    LoadModule行は既に有効になっていました。
    ついでに、待ち受けポート番号も変更します。
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
    
    -
    |
    |
    |
    |
    |
    |
    |
    |
    !
     
    -
    |
    |
    |
    !
     
     
     
     
     
     
     
    -
    !
     
     
     
     
     
     
    -
    |
    |
    |
    |
    |
    !
    -
    |
    |
    |
    |
    |
    |
    |
    |
    !
     
    -
    
    #
    # Listen: Allows you to bind Apache to specific IP addresses and/or
    # ports, in addition to the default. See also the <VirtualHost>
    # directive.
    #
    # Change this to Listen on specific IP addresses as shown below to
    # prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
    #
    #Listen 12.34.56.78:80
    Listen <ポート番号>
     
    #
    # Proxy Server directives. Uncomment the following lines to
    # enable the proxy server:
    #
    <IfModule mod_proxy.c>
    ProxyRequests On
     
    <Proxy *>
        Order deny,allow
        Deny from all
        Allow from all
     
        # Digest認証
        AuthType Digest
        AuthName "<認証ダイアログに表示したい文字列>"
        AuthUserFile <htdigestで生成する認証用ファイルのパス>
        AuthGroupFile /dev/null
        Require valid-user
    </Proxy>
     
    #
    # Enable/disable the handling of HTTP/1.1 "Via:" headers.
    # ("Full" adds the server version; "Block" removes all outgoing Via: headers)
    # Set to one of: Off | On | Full | Block
    #
    #ProxyVia On
     
    #
    # To enable a cache of proxied content, uncomment the following lines.
    # See http://httpd.apache.org/docs/2.2/mod/mod_cache.html for more details.
    #
    #<IfModule mod_disk_cache.c>
    #   CacheEnable disk /
    #   CacheRoot "/var/cache/mod_proxy"
    #</IfModule>
    #
     
    </IfModule>
    # End of proxy directives.
    
  3. Digest認証用ファイルを作成します。
    Everything is expanded.Everything is shortened.
      1
    
     
    
    <Apacheルート>/bin/htdigest -c <AuthUserFileで指定したパス> "<AuthNameで指定した文字列>" <ユーザ名>
  4. Apacheを再起動します。
    Everything is expanded.Everything is shortened.
      1
    
     
    
    /etc/init.d/httpd restart
  5. 以上で完了です。
    iptablesの設定は各自で見直して下さい。

検証時の環境

参考