【Squid FAQ】 最終更新日:2003-04-18

D-netプランページへ】【Squid Homeへ】 【FAQトップへ】

5. 構成に関する設定

今日のWebブラウザは、proxy(プロキシ)キャッシュをサポートしており、ブラウザは手動または自動設定で簡単にproxyを利用できるようになっています。

5.1 Netscape(Mozilla)の手動設定。

「編集」−「設定」−「詳細」−「プロシキ」で現れる画面のそれどれのプロトコルhttp, ssl, ftpでプロキシのサーバアドレストと待ち受けポート番号(デフォルト:3128)を指定します。

5.2 Netscape(Mozilla)の自動設定。

JavaScriptを使った設定ファイルを作成しておき、これをNetscape(Mozlla)で利用するように設定することで、自動的にProxyを探し出しリクエストをproxyへ送るように設定できます。
スクリプトはWebサーバに置いておく方法と、ローカルマシン上に置いておく方法があります。 Webサーバ上に置いておく方法の場合には詳しくはNetscapeのドキュメントを参照してください。Netscape(Mozilla)上の自動化のための設定のスクリーンショットを示しておきます。

上記の場合にはあるwebサイトにスクリプトを置いておくことで、自動化を有効にします。
以下はスクリプトをローカルマシン上に置いておく場合の設定例です。

以下にJavaScriptのサンプルを2つ示しておきます。
(proxy.pac : その1)
//We (www.is.co.za) run a central cache for our customers that they
//access through a firewall - thus if they want to connect to their intranet
//system (or anything in their domain at all) they have to connect
//directly - hence all the "fiddling" to see if they are trying to connect
//to their local domain.

//Replace each occurrence of company.com with your domain name
//and if you have some kind of intranet system, make sure
//that you put it's name in place of "internal" below.

//We also assume that your cache is called "cache.company.com", and
//that it runs on port 8080. Change it down at the bottom.

//(C) Oskar Pearson and the Internet Solution (http://www.is.co.za)

    function FindProxyForURL(url, host)
        {
            //If they have only specified a hostname, go directly.
            if (isPlainHostName(host))
                    return "DIRECT";

            //These connect directly if the machine they are trying to
            //connect to starts with "intranet" - ie http://intranet
            //Connect  directly if it is intranet.*
            //If you have another machine that you want them to
            //access directly, replace "internal*" with that
            //machine's name
            if (shExpMatch( host, "intranet*")||
                            shExpMatch(host, "internal*"))
                return "DIRECT";

            //Connect directly to our domains (NB for Important News)
            if (dnsDomainIs( host,"company.com")||
            //If you have another domain that you wish to connect to
            //directly, put it in here
                            dnsDomainIs(host,"sistercompany.com"))
                return "DIRECT";

            //So the error message "no such host" will appear through the
            //normal Netscape box - less support queries :)
            if (!isResolvable(host))
                    return "DIRECT";

            //We only cache http, ftp and gopher
            if (url.substring(0, 5) == "http:" ||
                            url.substring(0, 4) == "ftp:"||
                            url.substring(0, 7) == "gopher:")

            //Change the ":8080" to the port that your cache
            //runs on, and "cache.company.com" to the machine that
            //you run the cache on
                    return "PROXY cache.company.com:8080; DIRECT";

            //We don't cache WAIS
            if (url.substring(0, 5) == "wais:")
                    return "DIRECT";

            else
                    return "DIRECT";
        }
(proxy.pac : その2)
//
function FindProxyForURL(url, host) {
    if (isInNet(myIpAddress(), "192.168.0.0", "255.255.255.0")) {
        if ( dnsDomainIs(host, ".robata.org") || isPlainHostName(host) )  {
                return "DIRECT" ;
        } else {
                return "PROXY proxy1.robata.org:8080" ;
        }
    } else {
        if (isInNet(myIpAddress(), "172.16.0.0", "255.255.0.0")) {
                return "PROXY proxy2.robata.org:8080" ;
        } else {
                return "DIRECT" ;
        }
    }
}

5.3 Lynx,Mosaicの為の設定

LynxやMosaicでは、環境変数を指定することでプロキシを利用できます。
(bash(bsh)を使っている場合)
% http_proxy="http://mycache.example.com:3128/"
% gopher_proxy="http://mycache.example.com:3128/"
% ftp_proxy="http://mycache.example.com:3128/"
$ export http_proxy gopher_proxy ftp_proxy
(cshを使っている場合)
% setenv http_proxy http://my-proxy.domain.jp:8080/
% setenv gopher_proxy http://my-proxy.domain.jp:8080/
% setenv ftp_proxy http://my-proxy.domain.jp:8080/
Lynxでは Lynx.cfg ファイルに以下のように設定する事もできます。

http_proxy:http://my-proxy.domain.jp:8080/
ftp_proxy:http://my-proxy.domain.jp:8080/
gopher_proxy:http://my-proxy.domain.jp:8080/
D-netプランページへ】【Squid Homeへ】 【FAQトップへ】

Copyright© 1998-2003 ROBATA.ORG