274 277




Apache Server for Windows Little Black Book:Proxy Serving With Apache
function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) { var end = document.cookie.indexOf (";", j); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(j, end)); } i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } var m1=''; var gifstr=GetCookie("UsrType"); if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; } document.write(m1+m2+m3);            Keyword Title Author ISBN Publisher Imprint Brief Full  Advanced      Search  Search Tips Please Select ----------- Components Content Mgt Certification Databases Enterprise Mgt Fun/Games Groupware Hardware IBM Redbooks Intranet Dev Middleware Multimedia Networks OS Prod Apps Programming Security UI Web Services Webmaster Y2K ----------- New Titles ----------- Free Archive To access the contents, click the chapter and section titles. Apache Server for Windows Little Black Book (Publisher: The Coriolis Group) Author(s): Greg Holden with Matthew Keller ISBN: 1576103919 Publication Date: 01/01/99 function isIE4() { return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') ); } function bookMarkit() { var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0"; parent.location.href=url; //var win = window.open(url,"myitk"); //if(!isIE4()) // win.focus(); } Search this book:  















Previous
Table of Contents
Next




Another way to restrict access to the proxy server is to set up basic authentication (which is discussed in Chapter 9); for instance:



<Directory proxy:*>
AuthType Basic
AuthName ProxyServer
AuthUserFile c:/www/Apache/passwd
require valid-user
</Directory>


Of course, you don’t have to restrict access to the proxy server; you can simply include the proxy-related directives within a <Directory> block, like this:


<Directory proxy:*>
CacheRoot C:/www/cache
CacheSize 2048
CacheMaxExpire 24
</Directory>


Finally, you can also restrict access to the proxy to a specific protocol:



<Directory proxy:http:*>

</Directory>


This allows you to control HTTP requests to the server. You can replace HTTP with another protocol, such as FTP.


TIP:  You also have the option of including the proxy directives within a <Files> block to restrict access to your proxy server.

It can also be helpful to regard the proxy as a separate virtual host that is not connected with the rest of your Web server’s operation, as described in the following section.

Using IfModule To Set Up A Proxy Server
You can set up a virtual host to function as the proxy. This has the advantage of not interfering with the rest of your Web server functions. Yet, the proxy is still built in with your existing Apache Web server.

You can set up a virtual host to function as the proxy by using a special Apache care directive called IfModule. IfModule is used to specify directives from a module that is not always present in Apache. It takes this syntax:


<IfModule [!]module-name> … </IfModule>


The argument module-name represents the file name of the module at the time it was compiled. The default modules for Apache have file names such as mod.rewrite.c and mod.access.c. However, because mod.proxy is compiled in a DLL, you would use proxy_module as the argument. For example, if your proxy is named proxy.company.com and it is available on port 8000 of your server, you could add the following to access.conf:


<IfModule proxy_module>
Listen 10.0.0.1:8000
<VirtualHost 10.0.0.1:8000>
ProxyRequests On
CustomLog proxy_log "%h %l %u %t \"%r\" %s %b"
DocumentRoot C:/Apache/htdocs/proxy
</VirtualHost>
</IfModule>


Be sure to substitute your own server’s IP address for the one shown in the preceding example.

Enabling Document Cache
One of the most useful functions provided by a proxy server is the ability to store requests and responses that pass through it in disk cache. However, even if you have a proxy server up and running, it does not cache documents by default. You can enable caching by using the CacheRoot and CacheSize directives, with this syntax:


CacheRoot <directory>
CacheSize size-in-kilobytes


The CacheRoot directive specifies the location where cached files are to be stored by the proxy server. The files are held in a directory tree, and CacheRoot identifies the top level of the directory.
The CacheSize directive tells Apache how much space is to be set aside for the cached data. The default size is pretty small—only 5K. The size of proxy cache will probably grow above this limit quickly, so this is not a firm limit. However, when Apache performs “garbage collection” of the proxy cache area, the older cached items will be deleted until the cache size is at or below the size specified with CacheSize.

TIP:  It’s a good idea to specify a CacheSize number that is at least 20 to 40 percent lower than your available disk space.

You can also limit the complexity of the proxy cache area by using the CacheDirLevels and CacheDirLength directives, which follow this syntax:


CacheDirLevels number-of-levels
CacheDirLength number-of-characters


The CacheDirLevels directive controls the number of levels of subdirectories that will be occupied by the proxy cache files. The default is 3, which means that cached files will be stored three levels below the directory specified with CacheRoot.

TIP:  It is useful to use several subdirectories if your proxy server is very busy. You can then spread out the number of files among the directories, which spreads the burden among them. The downside is that it can be difficult to find files if you have several subdirectories through which to search. If your proxy isn’t terribly busy, you may want to reduce the setting to 1 so you only have to search through one subdirectory.

The CacheDirLength directive specifies how long each subdirectory name can be. The default is 1, which means each name will be one character long. If you increase the number to 2 or 3, for instance, you’ll provide for more subdirectories at each level.
By manually enabling disk caching and specifying a location for cache files, you’ll have greater control over the size of the proxy cache area. It can quickly consume large amounts of disk space. However, you can use the proxy directives described in subsequent sections to control which files are cached and how often the cache is cleaned out.
Keeping Specified Content Out Of Cache
One way to limit the number of files the proxy stores in cache is to specify locations or documents that you know you don’t want cached. This is often useful if you want to disable caching of certain Web servers on an intranet if you know your colleagues can access those servers from other places in the organization. You might do this for files the proxy has stored in the past that are very large in size or that contain content that you think is unimportant.

To identify items you want to keep out of proxy cache, you can use the NoCache directive, which follows this syntax:


NoCache <word|domain name|subnet|IP address>


NoCache works by specifying specific hosts or computers that you want to keep out of cache. You can list several of these as arguments to NoCache as long as each one is separated by a blank space; for example:


NoCache company.com company2.com another-company.com


You can also specify specific words to be matched and thus kept out of cache:



NoCache prospectus.htm stafflist.txt


In the preceding example, URLs submitted that include the files prospectus.htm and stafflist.txt will be excluded from cache. If you want to disable caching altogether, you would specify the following:



NoCache *






Previous
Table of Contents
Next






Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.



Wyszukiwarka

Podobne podstrony:
rozdzial (277)
274,2,artykul
nipponicumid)274
277 gotowy wykroj najprostsza sukienka
273 277
Vzduchovka ČZ 277
274?2109 operator piecow do obrobki cieplnej
274 275
Ustawa o ochr przyrody Dz U 1934 Nr 31, poz 274
277 278

więcej podobnych podstron