tailieunhanh - Apache Server 2 Bible Hungry Minds phần 5

Để giúp các nhà phát triển CGI, Apache có các bản ghi cho đầu ra CGI. Đối với mỗi lỗi chương trình CGI, các file bản ghi có chứa một vài dòng của các mục nhập. Hai dòng đầu tiên chứa các thời điểm yêu cầu, URI yêu cầu, tình trạng HTTP, tên chương trình CGI, và như vậy. | 290 Part II Web Site Administration else OK the URL is remote so check which proxy to use. if 0 5 http return PROXY 8080 else if 0 4 ftp return PROXY 8080 else if 0 6 https return PROXY 8080 else return DIRECT Listing 10-3 usr bin perl A Perl script that outputs proxy server configuration. Author Revision Id Get the remote host IP from the CGI environment variable REMOTE_HOST my client ENV REMOTE_HOST Print out the necessary content-type to let the browser know that this is a proxy configuration. print Content-type application x-ns-proxy-autoconfig n n If the request came from a host with IP address then output proxy configuration from subroutine specialClient if client 206 .171 .50 .51 specialClient Chapter 10 Setting up a Proxy Server 291 else If the request came from any other clients then send proxy configuration for all other clients otherClients exit 0 sub specialClient This subroutine outputs a proxy server configuration print FUNC function FindProxyForURL url host if isPlainHostName host dnsDomainIs host . return DIRECT else if shExpMatch host .com return PROXY 8080 else if shExpMatch host .edu return PROXY 8080 else return DIRECT FUNC sub otherClients This subroutine outputs a proxy server configuration print FUNC function FindProxyForURL url host return DIRECT FUNC 292 Part II Web Site Administration This script outputs a special proxy server configuration for a host with the IP address all other hosts get a different configuration. To access this proxy configuration I can set up the Netscape Navigator or IE to point to this script at http cgi-bin . For example in IE you can specify a URL such as the above as the automatic proxy configuration script address in Tools Internet Options Connections LAN Settings Use automatic configuration script option

TỪ KHÓA LIÊN QUAN